View in context in the libbitcoin Slack #general mirror.
handle_blockchain_block_header() and handle_blockchain_block_headers() methods. This was a little more than expected because version 1.4 added a checkpointing scheme designed to minimize header download at clients. Headers are small, and this feature introduces additional trust beyond SPV (trust of header checkpoints embedded in the wallet code).
Implementing this requires computing a unique merkle tree of all block hashes up to the given block - for any block on demand. This requires caching partial merkle root computations at fixed intervals across the full chain. The caching is fast and very small, and the query computations are reasonable. But it was a lot of moving parts to organize and test.
It is controllable via config, and we'd want it off unless supporting electrum. A large depth effectively precludes the cache, since it's cached on block height intervals of 2^depth. The cache is associated to blocks vs. heights (reorg safe) and append-only in the txs table. This should set to 11 (caching one merkle subtree root hash for every 2048 blocks) when serving electrum. Otherwise checkpointed header queries produce a merkle tree spanning the entire header chain (O(n) where n is the number of blocks) and will take some time.
[database] interval_depth = 255(edited)