refactor async mempool/block update callbacks

This commit is contained in:
Mononaut
2022-11-20 16:12:39 +09:00
parent 9a3be34450
commit 4adc9a13da
4 changed files with 34 additions and 112 deletions

View File

@@ -156,7 +156,8 @@ function makeBlockTemplates({ mempool, blockLimit, weightLimit, condenseRest }:
// this block is full
const exceededPackageTries = failures > 1000 && blockWeight > (config.MEMPOOL.BLOCK_WEIGHT_UNITS - 4000);
if (exceededPackageTries && (!condenseRest || blocks.length < blockLimit - 1)) {
const queueEmpty = top >= mempoolArray.length && modified.isEmpty();
if ((exceededPackageTries || queueEmpty) && (!condenseRest || blocks.length < blockLimit - 1)) {
// construct this block
if (transactions.length) {
blocks.push(dataToMempoolBlocks(transactions.map(t => mempool[t.txid]), blockSize, blockWeight, blocks.length));
@@ -209,7 +210,6 @@ function makeBlockTemplates({ mempool, blockLimit, weightLimit, condenseRest }:
tx.cpfpChecked = false;
tx.ancestors = [];
tx.bestDescendant = null;
tx.ancestors
blockTransactions.push(tx);
});
if (blockTransactions.length) {