I'm parsing out de blockxxxxx.dat files for the bitcoin blockchain. Are the blocks ordered by height? So is the order of the data for everybody the same?
1 Answer
No, they are in the order by which your node received the blocks. This can be in any particular order as nodes receive blocks out of order during the initial sync. Furthermore, some nodes will receive and store blocks that become stale, while other nodes (particularly ones that come online after that block has been found) will not. So the blk*.dat files between two nodes are likely to differ.
-
So if I want to order them, only way to do it is to match them up by previous_hash from the blockheader then, right? Commented Apr 24, 2021 at 15:22
-
1Yes, the order can only truly be determined by building the linked list.– Ava Chow ♦Commented Apr 24, 2021 at 21:40