|
|
|
@ -2670,18 +2670,22 @@ bool LoadBlockIndex()
|
|
|
|
|
if (!fReindex && !LoadBlockIndexDB())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Init with genesis block
|
|
|
|
|
//
|
|
|
|
|
if (mapBlockIndex.empty())
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool InitBlockIndex() {
|
|
|
|
|
// Check whether we're already initialized
|
|
|
|
|
if (pindexGenesisBlock != NULL)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// Use the provided setting for -txindex in the new database
|
|
|
|
|
fTxIndex = GetBoolArg("-txindex", false);
|
|
|
|
|
pblocktree->WriteFlag("txindex", fTxIndex);
|
|
|
|
|
printf("Initializing databases...\n");
|
|
|
|
|
|
|
|
|
|
if (fReindex)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// Only add the genesis block if not reindexing (in which case we reuse the one already on disk)
|
|
|
|
|
if (!fReindex) {
|
|
|
|
|
// Genesis Block:
|
|
|
|
|
// CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
|
|
|
|
|
// CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
|
|
|
|
@ -2722,6 +2726,7 @@ bool LoadBlockIndex()
|
|
|
|
|
assert(hash == hashGenesisBlock);
|
|
|
|
|
|
|
|
|
|
// Start new block file
|
|
|
|
|
try {
|
|
|
|
|
unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION);
|
|
|
|
|
CDiskBlockPos blockPos;
|
|
|
|
|
CValidationState state;
|
|
|
|
@ -2731,6 +2736,9 @@ bool LoadBlockIndex()
|
|
|
|
|
return error("LoadBlockIndex() : writing genesis block to disk failed");
|
|
|
|
|
if (!block.AddToBlockIndex(state, blockPos))
|
|
|
|
|
return error("LoadBlockIndex() : genesis block not accepted");
|
|
|
|
|
} catch(std::runtime_error &e) {
|
|
|
|
|
return error("LoadBlockIndex() : failed to initialize block database: %s", e.what());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|