View in context in the libbitcoin Slack #general mirror.
chain_state. This class is designed to init off the store and then prevent the need to ever hit the store (excepting chain splits) to determine chain state. The state just rolls forward in a simple struct from block to block. This was previous implementation that I adapted, almost the same. This hides all fork activation code and various ugly things like that, exposing it as a simple set of flags. Also maintains median time past, height and previous block hash. This can be set up to populate in full from the store for each block (how Core does it) or to roll state forward. I did the former yesterday and added the latter today. I measured the performance difference, and the roll forward cuts the typical full header sync time down from 30 secs to 15 secs. Without any validation or chain state the best I saw was 7-8 secs. With full header validation and rolling chain_state I saw a lot of 11-12 secs. This is obviously inconsequential for initial block download, but it does have bearing on the cost of validating a new block when the header arrives (mining scenario). The total time for one header, including network is about .015 ms.