Author

Topic: how long bitcoin core stores different branches for the case of reorg (Read 649 times)

jr. member
Activity: 49
Merit: 2
Thank you 2112 and gmaxwell!

The variable BlockMap mapBlockIndex is defined in validation.cpp

I couldn't find where it is initialized.

There is only a comment here:
https://github.com/bitcoin/bitcoin/blob/86ea3c2ff247bb2ba0fb50013c8ecdbaf8a9fe8f/src/txdb.cpp
Code:
   // Load mapBlockIndex
while (pcursor->Valid()) {
I think I found, it is here right?

-- txdb.cpp

CBlockIndex* pindexNew = insertBlockIndex(diskindex.GetBlockHash());

-- validation.cpp

CBlockIndex * InsertBlockIndex(uint256 hash)
{
    if (hash.IsNull())
        return NULL;

    // Return existing
    BlockMap::iterator mi = mapBlockIndex.find(hash);
    if (mi != mapBlockIndex.end())
        return (*mi).second;

    // Create new
    CBlockIndex* pindexNew = new CBlockIndex();
    if (!pindexNew)
        throw std::runtime_error(std::string(__func__) + ": new CBlockIndex failed");
    mi = mapBlockIndex.insert(std::make_pair(hash, pindexNew)).first;
    pindexNew->phashBlock = &((*mi).first);

    return pindexNew;
}
jr. member
Activity: 49
Merit: 2
Thank you 2112 and gmaxwell!

The variable BlockMap mapBlockIndex is defined in validation.cpp

I couldn't find where it is initialized.

There is only a comment here:
https://github.com/bitcoin/bitcoin/blob/86ea3c2ff247bb2ba0fb50013c8ecdbaf8a9fe8f/src/txdb.cpp
Code:
    // Load mapBlockIndex
while (pcursor->Valid()) {


staff
Activity: 4242
Merit: 8672
Pruning removes them when it removes other blocks of the same age,  otherwise forever. there is no point in having to rewrite data to save a couple megabytes here and there.
legendary
Activity: 2128
Merit: 1073
Forever.

Check the code servicing 'getchaintips' RPC call.
jr. member
Activity: 49
Merit: 2
Hi,

Could you please tell me how does bitcoin core stores different branches for a possible reorg?
Could you point me to the code?

Thank you very much!!! Smiley
Jump to: