@@ -899,7 +899,8 @@ class PeerManagerImpl final : public PeerManager
899899 */
900900 void FindNextBlocksToDownload (const Peer& peer, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
901901
902- std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > mapBlocksInFlight GUARDED_BY (cs_main);
902+ typedef std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator>> BlockDownloadMap;
903+ BlockDownloadMap mapBlocksInFlight GUARDED_BY (cs_main);
903904
904905 /* * When our tip was last updated. */
905906 std::atomic<std::chrono::seconds> m_last_tip_update{0s};
@@ -1117,7 +1118,7 @@ std::chrono::microseconds PeerManagerImpl::NextInvToInbounds(std::chrono::micros
11171118
11181119bool PeerManagerImpl::IsBlockRequested (const uint256& hash)
11191120{
1120- return mapBlocksInFlight.find (hash) != mapBlocksInFlight. end ( );
1121+ return mapBlocksInFlight.count (hash);
11211122}
11221123
11231124void PeerManagerImpl::RemoveBlockRequest (const uint256& hash, std::optional<NodeId> from_peer)
@@ -1161,7 +1162,7 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st
11611162 assert (state != nullptr );
11621163
11631164 // Short-circuit most stuff in case it is from the same node
1164- std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > ::iterator itInFlight = mapBlocksInFlight.find (hash);
1165+ BlockDownloadMap ::iterator itInFlight = mapBlocksInFlight.find (hash);
11651166 if (itInFlight != mapBlocksInFlight.end () && itInFlight->second .first == nodeid) {
11661167 if (pit) {
11671168 *pit = &itInFlight->second .second ;
@@ -4274,7 +4275,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
42744275 nodestate->m_last_block_announcement = GetTime ();
42754276 }
42764277
4277- std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > ::iterator blockInFlightIt = mapBlocksInFlight.find (pindex->GetBlockHash ());
4278+ BlockDownloadMap ::iterator blockInFlightIt = mapBlocksInFlight.find (pindex->GetBlockHash ());
42784279 bool fAlreadyInFlight = blockInFlightIt != mapBlocksInFlight.end ();
42794280
42804281 if (pindex->nStatus & BLOCK_HAVE_DATA) // Nothing to do here
@@ -4433,7 +4434,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
44334434 {
44344435 LOCK (cs_main);
44354436
4436- std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > ::iterator it = mapBlocksInFlight.find (resp.blockhash );
4437+ BlockDownloadMap ::iterator it = mapBlocksInFlight.find (resp.blockhash );
44374438 if (it == mapBlocksInFlight.end () || !it->second .second ->partialBlock ||
44384439 it->second .first != pfrom.GetId ()) {
44394440 LogPrint (BCLog::NET, " Peer %d sent us block transactions for block we weren't expecting\n " , pfrom.GetId ());
0 commit comments