cculianu / Fulcrum

A fast & nimble SPV Server for BCH, BTC, and LTC
Other
343 stars 77 forks source link

Add 3 new RPCs, plus add a new index: txhash -> txnum (for mapping tx's to their confirmed heights) #75

Closed cculianu closed 3 years ago

cculianu commented 3 years ago

Changes:

Performance and disk space implications:

This new index eats about 1GB on testnet3 and between ~3 - ~5GB or so on mainnet (the variability in how much it eats is due to the way rocksdb works). The index doesn't eat too much time in terms of the addBlock pipeline for synching -- rocksdb has incredibly fast inserts. Even so, we added a new CoTask which doles the work out in parallel in the addBlock function to add to this index in another worker thread while we are busy processing the block in our Controller thread.

Migration path & compatibility:

This index is implemented as a separate rocksdb database, which lives in the datadir under txhash2txnum/.

Servers will automatically build this index on startup from the existing txnum2txhash flat-file. Building it on testnet3 with an SSD takes ~1 minute and on mainnet from between 3 and 10 minutes, depending.

If downgrading from this version back to the 1.4.x or earlier series -- the new database is simply ignored by older versions. Admins can then later move back up to later Fulcrum and the index will be detected as "stale" on startup and rebuilt from scratch on first run.