From 5f45ce80f1d5e300d40e7792b596235d24b1e251 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Mon, 2 Dec 2024 22:18:17 +0000 Subject: [PATCH 1/2] filter accelerations before calculating pool positions --- backend/src/api/mempool-blocks.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/api/mempool-blocks.ts b/backend/src/api/mempool-blocks.ts index 6e547e653..eea850be5 100644 --- a/backend/src/api/mempool-blocks.ts +++ b/backend/src/api/mempool-blocks.ts @@ -688,7 +688,7 @@ class MempoolBlocks { [pool: string]: { name: string, block: number, vsize: number, accelerations: string[], complete: boolean }; } = {}; // prepare a list of accelerations in ascending order (we'll pop items off the end of the list) - const accQueue: { acceleration: Acceleration, rate: number, vsize: number }[] = Object.values(accelerations).map(acc => { + const accQueue: { acceleration: Acceleration, rate: number, vsize: number }[] = Object.values(accelerations).filter(acc => acc.txid in mempoolCache).map(acc => { let vsize = mempoolCache[acc.txid].vsize; for (const ancestor of mempoolCache[acc.txid].ancestors || []) { vsize += (ancestor.weight / 4); From e4868b70c18be4c4fc05abd19c30d82b1dd05631 Mon Sep 17 00:00:00 2001 From: Mononaut Date: Mon, 2 Dec 2024 22:19:01 +0000 Subject: [PATCH 2/2] more processBlockTemplates null checks --- backend/src/api/mempool-blocks.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/api/mempool-blocks.ts b/backend/src/api/mempool-blocks.ts index eea850be5..ba4ce2ed0 100644 --- a/backend/src/api/mempool-blocks.ts +++ b/backend/src/api/mempool-blocks.ts @@ -382,7 +382,7 @@ class MempoolBlocks { const ancestors: Ancestor[] = []; const descendants: Ancestor[] = []; - let ancestor: MempoolTransactionExtended + let ancestor: MempoolTransactionExtended; for (const cluster of clusters) { for (const memberTxid of cluster) { const mempoolTx = mempool[memberTxid]; @@ -462,7 +462,7 @@ class MempoolBlocks { for (let i = 0; i < block.length; i++) { const txid = block[i]; - if (txid) { + if (txid in mempool) { mempoolTx = mempool[txid]; // save position in projected blocks mempoolTx.position = { @@ -481,6 +481,9 @@ class MempoolBlocks { mempoolTx.acceleratedAt = acceleration?.added; mempoolTx.feeDelta = acceleration?.feeDelta; for (const ancestor of mempoolTx.ancestors || []) { + if (!(ancestor.txid in mempool)) { + continue; + } if (!mempool[ancestor.txid].acceleration) { mempool[ancestor.txid].cpfpDirty = true; }