I’ve been looking at the insight-api / bitcore-node projects. One thing I still don’t understand is why they sync the block chain to a new leveldb instance. They require a trusted instance of bitcoind, which stores and provides easy access by rpc / p2p to the whole block chain already. So what’s the architectural advantage / necessity of duplicating that data?
They use leveldb to store a whole lot of additional macro data. Were as with bitcoind your wallet tracks certain addresses, using leveldb allows insight to track all balances, among other things. Since a trusted bitcoind node is already needed, duplicating this for faster and better lookup doesn’t introduce any new issues really.
Thanks for the response. I understand that historically the insight database was needed to implement the address endpoints. Now that Bitcoin Core supports “watch-only addresses”, it would be simpler to use rpc methods. The issue with the sync is that it adds a fair amount of complexity to the code base and operation.
It is not exactly the same thing. With Insight you can query any address,
at any point in time, and obtain all its transactions and current
balance. With the
watch-only address feature on bitcoind v0.10 you can
import an address, but you need to rescan the blockchain to get the related
information (unless the address is new).
So, in certain use cases bitcoind’s watch-only feature could replace
insight’s address service, but not always.
Got it, thanks. watch-only is way too slow for this purpose because each time an address gets “imported” bitcoind rescans the whole block chain for transactions associated with it whereas insight / bitcore-node does the full scan once for all addresses and then maintains that in a database.
What does it mean that bitcoind has to rescan “unless the address is new”?
if the address is new, there’s no reason to rescan… nothing will be there. BUT, it would also need a way to know that the address is new. If it doesn’t, it would need to rescan anyway.