aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-27 17:12:22 -0700
committerAdam Soltys <[email protected]>2026-06-27 17:12:22 -0700
commitef183514e078169bf171e29b88c85aa16c8ecc75 (patch)
tree46145a9f14fad378439e1c57451b80a187176df6
parentb0b9a71ef4912350ecf188bf6a75d21e97adc06b (diff)
downloadcoinosv3-ef183514e078169bf171e29b88c85aa16c8ecc75.tar.gz
coinosv3-ef183514e078169bf171e29b88c85aa16c8ecc75.zip
Gate mempool discovery behind SP_MEMPOOL (default on; off spares a busy node)
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
-rw-r--r--tools/sp-indexer.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/sp-indexer.js b/tools/sp-indexer.js
index 7e34405..09f9a19 100644
--- a/tools/sp-indexer.js
+++ b/tools/sp-indexer.js
@@ -25,6 +25,10 @@ const PORT = Number(process.env.SP_PORT || 8888);
const START = Number(process.env.START_HEIGHT || 0);
const POLL_MS = Number(process.env.POLL_MS || 2000);
const DB_PATH = process.env.SP_DB || ':memory:';
+// Mempool (unconfirmed) discovery is great for fast feedback but adds RPC load on
+// Core (a getrawtransaction + prevout lookups per new taproot-output tx). On by
+// default; set SP_MEMPOOL=0 to disable (e.g. to spare a busy production node).
+const MEMPOOL = process.env.SP_MEMPOOL !== '0';
const auth = 'Basic ' + Buffer.from(`${RPC_USER}:${RPC_PASS}`).toString('base64');
let rpcId = 0;
@@ -132,7 +136,7 @@ async function sync() {
if (h % 100 === 0 || h === tip) console.log(`indexed height ${h}/${tip} (${items.length} sp-tx)`);
}
if (!live) { live = true; console.log('caught up — pushing new blocks over websocket'); }
- await mempoolSync(); // blocks just changed the mempool — reconcile pending
+ if (MEMPOOL) await mempoolSync(); // blocks just changed the mempool — reconcile pending
} catch (e) {
console.error('sync error:', e.message);
}
@@ -290,4 +294,4 @@ if (process.env.SP_ZMQ) {
console.log(`zmq: subscribed to hashblock at ${process.env.SP_ZMQ}`);
}
setInterval(sync, POLL_MS); // backstop (and the only trigger when SP_ZMQ is unset)
-setInterval(mempoolSync, Number(process.env.MEMPOOL_POLL_MS || 2500)); // unconfirmed SP discovery
+if (MEMPOOL) setInterval(mempoolSync, Number(process.env.MEMPOOL_POLL_MS || 2500)); // unconfirmed SP discovery