diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -174,7 +174,7 @@ * Set mapBlockSource[hash].second to false if the node should not be punished * if the block is invalid. */ -std::map> mapBlockSource GUARDED_BY(cs_main); +std::map> mapBlockSource GUARDED_BY(cs_main); /** * Filter for transactions that were recently rejected by AcceptToMemoryPool. @@ -201,7 +201,7 @@ * Blocks that are in flight, and that are in the queue to be downloaded. */ struct QueuedBlock { - uint256 hash; + BlockHash hash; //! Optional. const CBlockIndex *pindex; //! Whether this block has validated headers at the time of request. @@ -209,7 +209,7 @@ //! Optional, used for CMPCTBLOCK downloads std::unique_ptr partialBlock; }; -std::map::iterator>> +std::map::iterator>> mapBlocksInFlight GUARDED_BY(cs_main); /** Stack of nodes which we have set to announce using compact blocks */ @@ -523,9 +523,9 @@ // Returns a bool indicating whether we requested this block. // Also used if a block was /not/ received and timed out or started with another // peer. -static bool MarkBlockAsReceived(const uint256 &hash) +static bool MarkBlockAsReceived(const BlockHash &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { - std::map::iterator>>::iterator itInFlight = mapBlocksInFlight.find(hash); if (itInFlight != mapBlocksInFlight.end()) { @@ -558,7 +558,7 @@ // same peer // pit will only be valid as long as the same cs_main lock is being held. static bool -MarkBlockAsInFlight(const Config &config, NodeId nodeid, const uint256 &hash, +MarkBlockAsInFlight(const Config &config, NodeId nodeid, const BlockHash &hash, const Consensus::Params &consensusParams, const CBlockIndex *pindex = nullptr, std::list::iterator **pit = nullptr) @@ -567,7 +567,7 @@ assert(state != nullptr); // Short-circuit most stuff in case it is from the same node. - std::map::iterator>>::iterator itInFlight = mapBlocksInFlight.find(hash); if (itInFlight != mapBlocksInFlight.end() && @@ -1464,8 +1464,8 @@ const CValidationState &state) { LOCK(cs_main); - const uint256 hash(block.GetHash()); - std::map>::iterator it = + const BlockHash hash = block.GetHash(); + std::map>::iterator it = mapBlockSource.find(hash); if (state.IsInvalid()) { @@ -3209,7 +3209,7 @@ nodestate->m_last_block_announcement = GetTime(); } - std::map::iterator>>:: iterator blockInFlightIt = mapBlocksInFlight.find(pindex->GetBlockHash()); @@ -3421,7 +3421,7 @@ { LOCK(cs_main); - std::map::iterator>>:: iterator it = mapBlocksInFlight.find(resp.blockhash); if (it == mapBlocksInFlight.end() || @@ -3559,7 +3559,7 @@ // AcceptBlock(). bool forceProcessing = pfrom->HasPermission(PF_NOBAN) && !::ChainstateActive().IsInitialBlockDownload(); - const uint256 hash(pblock->GetHash()); + const BlockHash hash = pblock->GetHash(); { LOCK(cs_main); // Also always process if we requested the block explicitly, as we @@ -3576,7 +3576,7 @@ pfrom->nLastBlockTime = GetTime(); } else { LOCK(cs_main); - mapBlockSource.erase(pblock->GetHash()); + mapBlockSource.erase(hash); } return true; }