4
0
I am trying to understand the structure of the underlying block chain stored in the core implementation (or rather just the BLK files used by a fullnode). My question is ; does the block chain store the complete tree structure , i.e all the forks which were encountered? Or does it purge the entries once a fork is resolved.
If i were to read the blk files sequentially , can i assume that every single block read is correctly ordered and no forks are present?
Thanks!
3To answer the question more directly: if you read the blk files directly, you would find the chain's blocks out of order, potentially with gaps in between, including forked off blocks, and the format may change in future versions. – Pieter Wuille – 2017-04-11T07:10:04.980
@PieterWuille many thanks for the clarification. – Bobo – 2017-04-11T13:57:41.120
@PieterWuille you'r wrong. While reading blk files with some math you can find order of blockchain exclude of any gaps or forks. Perhaps. – D L – 2017-04-12T02:56:15.177
3I wrote that code in Core. Yes, you can scan for all blocks and afterwards figure out the longest chain, and filter out garbage. But that's not what the question was about. On disk, the blocks are out of order. – Pieter Wuille – 2017-04-12T06:23:23.093