I parsed the block00000.dat using python code:
class BlockFile:
def __init__(self, block_filename):
self.block_filename = block_filename
self.blockchain = open(block_filename, 'rb', buffering=16*1024*1024)
def get_next_block(self):
while True:
block = Block(self.blockchain)
if block.is_ready:
yield block
else:
break
The full code is
https://github.com/keviny/bitcoin-block-parser/blob/master/block.py
It is very strange that the order of block in block00000 in different from the number in blockchain.info.
For example:
....
258 00000000613da6433c0f6c61d8bcb17c39603dd4a8595142359905b18b84edcd
259 000000007964a0e8b97bbea93e937c63d4097c42ccb4db464b1ab3047c62869c
260 000000001a748e1c97226c59b9ddf79a54e0857116808a1b5610a52aef4ed5b5
261 0000000025f2bb2ee58597083e13079899ecc6f2bb7e8bfd57e66b324b05d654
262 00000000d80530efa37319e4b4508b0759fdab8ea8a81272cbe8986881489507
....
The # in blockchain.info is:
258->block #257 (it is ok, because we use different start)
259->block #281
260->block #258
261->block #282
262->block #297
Is this by design, and I need to iterate all the blocks in block0000.dat, then sort by the time in blockheader to get the right block order?