Author

Topic: How to memory map blkindex.dat? (Read 616 times)

sr. member
Activity: 293
Merit: 250
Director - www.cubeform.io
May 21, 2015, 12:06:24 PM
#4
To clarify,  As mentioned the blk*.dat are the actual dumped blocks.
The format is:

4 bytes: network message start (0xf9, 0xbe, 0xb4, 0xd9)
4 bytes: block size N (little endian)
N bytes: block raw data (see https://en.bitcoin.it/wiki/Protocol_specification#block)

However, the blkindex.dat is a berkely db file, not a raw dump and contains where and in which blk*.dat file the block is contained.

--edit-- Note: this applies to versions <0.8 as the format was changed.
hero member
Activity: 690
Merit: 501
May 21, 2015, 11:55:31 AM
#3
It follows the network protocol.  They take the network serialization and dump it to disk.  Unused space at the end of the file is left as all zeros.

Protocol messages have this format.

Blocks are "block" type (and all zeros) for the command.

Blocks are given here.

Got it! Thanks
legendary
Activity: 1232
Merit: 1084
May 21, 2015, 11:38:44 AM
#2
It follows the network protocol.  They take the network serialization and dump it to disk.  Unused space at the end of the file is left as all zeros.

Protocol messages have this format.

Blocks are "block" type (and all zeros) for the command.

Blocks are given here.
hero member
Activity: 690
Merit: 501
May 21, 2015, 09:07:09 AM
#1
Hi,

I want to mmap blkindex.dat to have a pointer to each CBlockIndex in the file. I see there are the 4 magic bytes at the beginning, followed by some zeroes and then the genesis block. Anybody familiar with the exact layout?
Jump to: