diff --git a/src/avalanche/processor.cpp b/src/avalanche/processor.cpp --- a/src/avalanche/processor.cpp +++ b/src/avalanche/processor.cpp @@ -277,13 +277,12 @@ { LOCK(cs_main); for (const auto &v : votes) { - BlockMap::iterator mi = mapBlockIndex.find(BlockHash(v.GetHash())); - if (mi == mapBlockIndex.end()) { + auto pindex = LookupBlockIndex(BlockHash(v.GetHash())); + if (!pindex) { // This should not happen, but just in case... continue; } - CBlockIndex *pindex = mi->second; if (!IsWorthPolling(pindex)) { // There is no point polling this block. continue; @@ -428,12 +427,10 @@ { LOCK(cs_main); - BlockMap::iterator mi = mapBlockIndex.find(BlockHash(inv.hash)); - if (mi == mapBlockIndex.end()) { + pindex = LookupBlockIndex(BlockHash(inv.hash)); + if (!pindex) { continue; } - - pindex = mi->second; } auto w = vote_records.getWriteView(); diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3622,10 +3622,9 @@ uint32_t error = -1; if (inv.type == MSG_BLOCK) { - BlockMap::iterator mi = - mapBlockIndex.find(BlockHash(inv.hash)); - if (mi != mapBlockIndex.end()) { - error = ::ChainActive().Contains(mi->second) ? 0 : 1; + auto blockIndex = LookupBlockIndex(BlockHash(inv.hash)); + if (blockIndex) { + error = ::ChainActive().Contains(blockIndex) ? 0 : 1; } }