diff options
| author | Adam Soltys <[email protected]> | 2026-06-27 17:38:03 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-06-27 17:38:03 -0700 |
| commit | 97b32b97edea28b72f9be3dd82c468f57f401926 (patch) | |
| tree | f0b7300c7ec40866b5f36c68a1b7d1a47a908e36 /tools | |
| parent | 700efba34e34a8282a7853cbbdaa0f7de21e218c (diff) | |
| download | coinosv3-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]>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/sp-indexer.js | 8 |
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; |
