@@ -38,7 +38,7 @@ using namespace boost;
3838
3939CCriticalSection cs_main;
4040
41- map<uint256, CBlockIndex*> mapBlockIndex;
41+ BlockMap mapBlockIndex;
4242CChain chainActive;
4343int64_t nTimeBestReceived = 0 ;
4444CWaitableCriticalSection csBestBlock;
@@ -328,7 +328,7 @@ void ProcessBlockAvailability(NodeId nodeid) {
328328 assert (state != NULL );
329329
330330 if (state->hashLastUnknownBlock != 0 ) {
331- map<uint256, CBlockIndex*> ::iterator itOld = mapBlockIndex.find (state->hashLastUnknownBlock );
331+ BlockMap ::iterator itOld = mapBlockIndex.find (state->hashLastUnknownBlock );
332332 if (itOld != mapBlockIndex.end () && itOld->second ->nChainWork > 0 ) {
333333 if (state->pindexBestKnownBlock == NULL || itOld->second ->nChainWork >= state->pindexBestKnownBlock ->nChainWork )
334334 state->pindexBestKnownBlock = itOld->second ;
@@ -344,7 +344,7 @@ void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
344344
345345 ProcessBlockAvailability (nodeid);
346346
347- map<uint256, CBlockIndex*> ::iterator it = mapBlockIndex.find (hash);
347+ BlockMap ::iterator it = mapBlockIndex.find (hash);
348348 if (it != mapBlockIndex.end () && it->second ->nChainWork > 0 ) {
349349 // An actually better block was announced.
350350 if (state->pindexBestKnownBlock == NULL || it->second ->nChainWork >= state->pindexBestKnownBlock ->nChainWork )
@@ -434,7 +434,7 @@ CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
434434CBlockIndex *CChain::FindFork (const CBlockLocator &locator) const {
435435 // Find the first block the caller has in the main chain
436436 BOOST_FOREACH (const uint256& hash, locator.vHave ) {
437- std::map<uint256, CBlockIndex*> ::iterator mi = mapBlockIndex.find (hash);
437+ BlockMap ::iterator mi = mapBlockIndex.find (hash);
438438 if (mi != mapBlockIndex.end ())
439439 {
440440 CBlockIndex* pindex = (*mi).second ;
@@ -2068,7 +2068,7 @@ CBlockIndex* AddToBlockIndex(CBlockHeader& block)
20682068{
20692069 // Check for duplicate
20702070 uint256 hash = block.GetHash ();
2071- std::map<uint256, CBlockIndex*> ::iterator it = mapBlockIndex.find (hash);
2071+ BlockMap ::iterator it = mapBlockIndex.find (hash);
20722072 if (it != mapBlockIndex.end ())
20732073 return it->second ;
20742074
@@ -2079,9 +2079,9 @@ CBlockIndex* AddToBlockIndex(CBlockHeader& block)
20792079 LOCK (cs_nBlockSequenceId);
20802080 pindexNew->nSequenceId = nBlockSequenceId++;
20812081 }
2082- map<uint256, CBlockIndex*> ::iterator mi = mapBlockIndex.insert (make_pair (hash, pindexNew)).first ;
2082+ BlockMap ::iterator mi = mapBlockIndex.insert (make_pair (hash, pindexNew)).first ;
20832083 pindexNew->phashBlock = &((*mi).first );
2084- map<uint256, CBlockIndex*> ::iterator miPrev = mapBlockIndex.find (block.hashPrevBlock );
2084+ BlockMap ::iterator miPrev = mapBlockIndex.find (block.hashPrevBlock );
20852085 if (miPrev != mapBlockIndex.end ())
20862086 {
20872087 pindexNew->pprev = (*miPrev).second ;
@@ -2294,7 +2294,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
22942294 AssertLockHeld (cs_main);
22952295 // Check for duplicate
22962296 uint256 hash = block.GetHash ();
2297- std::map<uint256, CBlockIndex*> ::iterator miSelf = mapBlockIndex.find (hash);
2297+ BlockMap ::iterator miSelf = mapBlockIndex.find (hash);
22982298 CBlockIndex *pindex = NULL ;
22992299 if (miSelf != mapBlockIndex.end ()) {
23002300 pindex = miSelf->second ;
@@ -2323,7 +2323,7 @@ bool AcceptBlockHeader(CBlockHeader& block, CValidationState& state, CBlockIndex
23232323 CBlockIndex* pindexPrev = NULL ;
23242324 int nHeight = 0 ;
23252325 if (hash != Params ().HashGenesisBlock ()) {
2326- map<uint256, CBlockIndex*> ::iterator mi = mapBlockIndex.find (block.hashPrevBlock );
2326+ BlockMap ::iterator mi = mapBlockIndex.find (block.hashPrevBlock );
23272327 if (mi == mapBlockIndex.end ())
23282328 return state.DoS (10 , error (" AcceptBlock() : prev block not found" ), 0 , " bad-prevblk" );
23292329 pindexPrev = (*mi).second ;
@@ -2517,7 +2517,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
25172517 return error (" ProcessBlock() : CheckBlock FAILED" );
25182518
25192519 // If we don't already have its previous block (with full data), shunt it off to holding area until we get it
2520- std::map<uint256, CBlockIndex*> ::iterator it = mapBlockIndex.find (pblock->hashPrevBlock );
2520+ BlockMap ::iterator it = mapBlockIndex.find (pblock->hashPrevBlock );
25212521 if (pblock->hashPrevBlock != 0 && (it == mapBlockIndex.end () || !(it->second ->nStatus & BLOCK_HAVE_DATA)))
25222522 {
25232523 LogPrintf (" ProcessBlock: ORPHAN BLOCK %lu, prev=%s\n " , (unsigned long )mapOrphanBlocks.size (), pblock->hashPrevBlock .ToString ());
@@ -2799,7 +2799,7 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
27992799 return NULL ;
28002800
28012801 // Return existing
2802- map<uint256, CBlockIndex*> ::iterator mi = mapBlockIndex.find (hash);
2802+ BlockMap ::iterator mi = mapBlockIndex.find (hash);
28032803 if (mi != mapBlockIndex.end ())
28042804 return (*mi).second ;
28052805
@@ -2876,7 +2876,7 @@ bool static LoadBlockIndexDB()
28762876 LogPrintf (" LoadBlockIndexDB(): transaction index %s\n " , fTxIndex ? " enabled" : " disabled" );
28772877
28782878 // Load pointer to end of best chain
2879- std::map<uint256, CBlockIndex*> ::iterator it = mapBlockIndex.find (pcoinsTip->GetBestBlock ());
2879+ BlockMap ::iterator it = mapBlockIndex.find (pcoinsTip->GetBestBlock ());
28802880 if (it == mapBlockIndex.end ())
28812881 return true ;
28822882 chainActive.SetTip (it->second );
@@ -3034,7 +3034,7 @@ void PrintBlockTree()
30343034 AssertLockHeld (cs_main);
30353035 // pre-compute tree structure
30363036 map<CBlockIndex*, vector<CBlockIndex*> > mapNext;
3037- for (map<uint256, CBlockIndex*> ::iterator mi = mapBlockIndex.begin (); mi != mapBlockIndex.end (); ++mi)
3037+ for (BlockMap ::iterator mi = mapBlockIndex.begin (); mi != mapBlockIndex.end (); ++mi)
30383038 {
30393039 CBlockIndex* pindex = (*mi).second ;
30403040 mapNext[pindex->pprev ].push_back (pindex);
@@ -3280,7 +3280,7 @@ void static ProcessGetData(CNode* pfrom)
32803280 if (inv.type == MSG_BLOCK || inv.type == MSG_FILTERED_BLOCK)
32813281 {
32823282 bool send = false ;
3283- map<uint256, CBlockIndex*> ::iterator mi = mapBlockIndex.find (inv.hash );
3283+ BlockMap ::iterator mi = mapBlockIndex.find (inv.hash );
32843284 if (mi != mapBlockIndex.end ())
32853285 {
32863286 // If the requested block is at a height below our last
@@ -3711,7 +3711,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
37113711 if (locator.IsNull ())
37123712 {
37133713 // If locator is null, return the hashStop block
3714- map<uint256, CBlockIndex*> ::iterator mi = mapBlockIndex.find (hashStop);
3714+ BlockMap ::iterator mi = mapBlockIndex.find (hashStop);
37153715 if (mi == mapBlockIndex.end ())
37163716 return true ;
37173717 pindex = (*mi).second ;
@@ -4513,7 +4513,7 @@ class CMainCleanup
45134513 CMainCleanup () {}
45144514 ~CMainCleanup () {
45154515 // block headers
4516- std::map<uint256, CBlockIndex*> ::iterator it1 = mapBlockIndex.begin ();
4516+ BlockMap ::iterator it1 = mapBlockIndex.begin ();
45174517 for (; it1 != mapBlockIndex.end (); it1++)
45184518 delete (*it1).second ;
45194519 mapBlockIndex.clear ();
0 commit comments