Use tokio async/await instead of callbacks

This commit is contained in:
junderw authored and Mononaut committed 2023-07-03 10:18:17 -04:00
1 parent 99101ddc4f
commit 46fb6a68eb
6 files changed
+148 -67

No files matched your search

+3 -11
View File
@@ -342,12 +342,7 @@ class MempoolBlocks {
// run the block construction algorithm in a separate thread, and wait for a result
try {
const { blocks, rates, clusters } = this.convertNapiResultTxids(
await new Promise((resolve) => {
napiAddon.make(
new Uint8Array(mempoolBuffer),
resolve,
);
})
await napiAddon.make(new Uint8Array(mempoolBuffer)),
);
this.rustInitialized = true;
const processed = this.processBlockTemplates(newMempool, blocks, rates, clusters, saveResults);
@@ -381,13 +376,10 @@ class MempoolBlocks {
// run the block construction algorithm in a separate thread, and wait for a result
try {
const { blocks, rates, clusters } = this.convertNapiResultTxids(
await new Promise((resolve) => {
napiAddon.update(
await napiAddon.update(
new Uint8Array(addedBuffer),
new Uint8Array(removedBuffer),
resolve,
);
})
),
);
this.processBlockTemplates(newMempool, blocks, rates, clusters, saveResults);
logger.debug(`RUST updateBlockTemplates completed in ${(Date.now() - start)/1000} seconds`);