blzjs
blzjs copied to clipboard
DB Batch transaction suggestion
Working on hackahon project I profiled your testnet library in case of performance. It takes 3500-5500 ms for writing operation for the moment. From my opinion it depends on blockchain latency.
My suggestion is to add the following functions:
const tx = bluzelle.startTransaction() // returns pointer to batch transaction
tx.set("key", "value") // add an operation to batch transaction
const gasLeft = tx.gasLeft() // provides estimation of gas left for current batch transaction
const neededGas = tx.estimate.set("key2", "value2"); // provides estimated qty of gas for this operation
// The following code adds another operation if it's enough gas for that
if (gasLeft > neededGas) {
tx.set("key2", "value2");
}
tx.submit(); // submit transaction to DB
With this functionality, as a developer I would be able make very efficient request programmatically and improve the performance.
@scottburch This is a request for a batch function, which we do not actually support yet on the backend.
@MikaelLazarev Is my assessment correct?