ZeroXn / blockchain

Automatically exported from code.google.com/p/blockchain
0 stars 0 forks source link

Code does not go past first block #1

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I use the following code:

    BlockChain *b = createBlockChain("/home/XXXXX/.bitcoin/blocks");
    if ( b )
    {
        const BlockChain::Block *block = b->readBlock();
        while ( block )
        {
            block = b->readBlock();
        }
        b->release();
    }

Processing of the first block (blk00000.dat) goes fine. But when the code goes 
to blk00001.dat it hits an error.

Output from the program:

Successfully opened block-chain input file 
'/home/stick/.bitcoin/blocks/blk00000.dat'
Warning: Missing block-header; early termination of this block-data file.
Successfully opened block-chain input file 
'/home/stick/.bitcoin/blocks/blk00001.dat'
Advanced to the next data file; but it does not start with a valid block.  
Aborting reading the block-chain.

Original issue reported on code.google.com by rusn...@gmail.com on 24 Aug 2013 at 10:02

GoogleCodeExporter commented 8 years ago
I use the code on real data from bitcoin 0.8.3.

Original comment by rusn...@gmail.com on 24 Aug 2013 at 10:03

GoogleCodeExporter commented 8 years ago
After failing to read the correct magic (because the end of blk00000.dat is 
padded with zeroes) it calls openBlock() which opens blk0001.dat.  However fph 
is not reassigned so it then continues to read from the original.   One line 
fix in the attached diff.

Original comment by samjes...@gmail.com on 9 Oct 2013 at 1:20

Attachments: