aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-27 17:38:03 -0700
committerAdam Soltys <[email protected]>2026-06-27 17:38:03 -0700
commit97b32b97edea28b72f9be3dd82c468f57f401926 (patch)
treef0b7300c7ec40866b5f36c68a1b7d1a47a908e36
parent700efba34e34a8282a7853cbbdaa0f7de21e218c (diff)
downloadcoinosv3-97b32b97edea28b72f9be3dd82c468f57f401926.tar.gz
coinosv3-97b32b97edea28b72f9be3dd82c468f57f401926.zip
Skip the mempool backlog on startup for large (mainnet) mempools
First mempool pass over a >200-tx mempool would fire thousands of getrawtransaction calls at the node in a burst. Mark the existing backlog seen and scan only new arrivals instead; small (regtest) mempools still scan fully. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
-rw-r--r--tools/sp-indexer.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/sp-indexer.js b/tools/sp-indexer.js
index 934c55c..5611bb5 100644
--- a/tools/sp-indexer.js
+++ b/tools/sp-indexer.js
@@ -169,10 +169,18 @@ async function scanMempoolTx(txid) {
return { txid: tx.txid, tweak: Buffer.from(tweak).toString('hex'), outputs };
}
+let mempoolInit = false;
async function mempoolSync() {
try {
const txids = await rpc('getrawmempool', []);
const inPool = new Set(txids);
+ if (!mempoolInit) {
+ mempoolInit = true;
+ // Don't scan a large (mainnet) backlog on startup — that's thousands of
+ // getrawtransaction calls in a burst on the node. Mark it seen and watch
+ // only new arrivals. A small (regtest) mempool is cheap, so scan it.
+ if (txids.length > 200) { for (const txid of txids) mempoolSeen.set(txid, null); return; }
+ }
let changed = false;
for (const txid of txids) {
if (mempoolSeen.has(txid)) continue;