libbitcoin/libbitcoin-database

[master] Header storage exceedingly slow.

evoskuil opened this issue · 2 comments

It takes about 25 seconds to store 1000 headers, in server or node, Windows or Linux, but only on testnet. Nothing unusual logged. Verified in debugger that the time is consumed by:

void block_database::push(const chain::header& header, size_t height,
    uint32_t median_time_past, uint32_t checksum, link_type tx_start,
    size_t tx_count, uint8_t state)
{
    ...
}

Able to reproduce in mainnet.

This was the result of not caching chain state. Testnet requires 2016 bits values for every block except for each 2016th (retarget). The problem is similar for mainnet (bip34 activations, also applicable to testnet). Chain state caching and promotion eliminates this problem.