Compare commits

..

4 Commits

Author SHA1 Message Date
Mononaut
7569c6a394 Avoid initializing rbf cache in worker threads 2023-08-24 22:00:25 +09:00
Mononaut
d67285c683 Avoid initializing redis in worker threads 2023-08-24 22:00:25 +09:00
Mononaut
2b7ac32c22 Parallelize block summary/cpfp indexing with worker threads 2023-08-24 22:00:25 +09:00
Mononaut
df596ab5bf Parallelize block indexing with worker threads 2023-08-24 22:00:25 +09:00

View File

@@ -18,15 +18,20 @@ if (parentPort) {
}
async function indexBlockSummary(hash: string, height: number): Promise<void> {
const block = await bitcoinClient.getBlock(hash, 2);
const txs = block.tx.map(tx => {
tx.fee = Math.round(tx.fee * 100_000_000);
tx.vout.forEach((vout) => {
vout.value = Math.round(vout.value * 100000000);
let txs;
if (config.MEMPOOL.BACKEND === 'esplora') {
txs = (await bitcoinApi.$getTxsForBlock(hash)).map(tx => transactionUtils.extendTransaction(tx));
} else {
const block = await bitcoinClient.getBlock(hash, 2);
txs = block.tx.map(tx => {
tx.fee = Math.round(tx.fee * 100_000_000);
tx.vout.forEach((vout) => {
vout.value = Math.round(vout.value * 100000000);
});
tx.vsize = Math.round(tx.weight / 4); // required for backwards compatibility
return tx;
});
tx.vsize = Math.round(tx.weight / 4); // required for backwards compatibility
return tx;
});
}
const cpfpSummary = await blocks.$indexCPFP(hash, height, txs);
await blocks.$getStrippedBlockTransactions(hash, true, true, cpfpSummary, height); // This will index the block summary