aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-08-19 00:33:01 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-10-20 23:08:57 +0200
commit857c61df0b71c8a0482b1bf8fc55849f8ad831b8 (patch)
treee404a80e1070d495b18fe81c70378cf2a5ee60c7 /src/init.cpp
parent4fea06db25108e7f72710bf22c3d1896707eeb74 (diff)
Prepare database format for multi-stage block processing
This commit adds a status field and a transaction counter to the block indexes.
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp35
1 files changed, 3 insertions, 32 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 85aa4f6007..99e2bba376 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -781,38 +781,9 @@ bool AppInit2()
// ********************************************************* Step 9: import blocks
// scan for better chains in the block chain database, that are not yet connected in the active best chain
- CBlockIndex *pindexFoundBest = pindexBest;
- for (std::map<uint256,CBlockIndex*>::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) {
- CBlockIndex *pindex = it->second;
- if (pindexFoundBest==NULL || pindex->bnChainWork > pindexFoundBest->bnChainWork)
- pindexFoundBest = pindex;
- }
- if (pindexFoundBest != pindexBest) {
- uiInterface.InitMessage(_("Importing blocks from block database..."));
- uint64 nTxs = 0;
- uint64 nBlocks = 0;
- std::vector<CBlockIndex*> vAttach;
- vAttach.reserve(pindexFoundBest->nHeight - (pindexBest==NULL ? 0 : pindexBest->nHeight));
- while (pindexFoundBest && pindexFoundBest->bnChainWork > (pindexBest==NULL ? 0 : pindexBest->bnChainWork)) {
- vAttach.push_back(pindexFoundBest);
- pindexFoundBest = pindexFoundBest->pprev;
- }
- for (std::vector<CBlockIndex*>::reverse_iterator it = vAttach.rbegin(); it != vAttach.rend(); it++) {
- CBlockIndex *pindex = *it;
- CBlock block;
- if (!block.ReadFromDisk(pindex))
- break;
- nTxs += block.vtx.size();
- nBlocks++;
- if (pindex->nHeight == 0 || nTxs + nBlocks*3 > 500) {
- nTxs=0;
- nBlocks=0;
- block.SetBestChain(pindex);
- }
- if (fRequestShutdown)
- break;
- }
- }
+ uiInterface.InitMessage(_("Importing blocks from block database..."));
+ if (!ConnectBestBlock())
+ strErrors << "Failed to connect best block";
std::vector<boost::filesystem::path> *vPath = new std::vector<boost::filesystem::path>();
if (mapArgs.count("-loadblock"))