@@ -899,7 +899,8 @@ class PeerManagerImpl final : public PeerManager
899
899
*/
900
900
void FindNextBlocksToDownload (const Peer& peer, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
901
901
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);
903
904
904
905
/* * When our tip was last updated. */
905
906
std::atomic<std::chrono::seconds> m_last_tip_update{0s};
@@ -1117,7 +1118,7 @@ std::chrono::microseconds PeerManagerImpl::NextInvToInbounds(std::chrono::micros
1117
1118
1118
1119
bool PeerManagerImpl::IsBlockRequested (const uint256& hash)
1119
1120
{
1120
- return mapBlocksInFlight.find (hash) != mapBlocksInFlight. end ( );
1121
+ return mapBlocksInFlight.count (hash);
1121
1122
}
1122
1123
1123
1124
void PeerManagerImpl::RemoveBlockRequest (const uint256& hash, std::optional<NodeId> from_peer)
@@ -1161,7 +1162,7 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st
1161
1162
assert (state != nullptr );
1162
1163
1163
1164
// 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);
1165
1166
if (itInFlight != mapBlocksInFlight.end () && itInFlight->second .first == nodeid) {
1166
1167
if (pit) {
1167
1168
*pit = &itInFlight->second .second ;
@@ -4274,7 +4275,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
4274
4275
nodestate->m_last_block_announcement = GetTime ();
4275
4276
}
4276
4277
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 ());
4278
4279
bool fAlreadyInFlight = blockInFlightIt != mapBlocksInFlight.end ();
4279
4280
4280
4281
if (pindex->nStatus & BLOCK_HAVE_DATA) // Nothing to do here
@@ -4433,7 +4434,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
4433
4434
{
4434
4435
LOCK (cs_main);
4435
4436
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 );
4437
4438
if (it == mapBlocksInFlight.end () || !it->second .second ->partialBlock ||
4438
4439
it->second .first != pfrom.GetId ()) {
4439
4440
LogPrint (BCLog::NET, " Peer %d sent us block transactions for block we weren't expecting\n " , pfrom.GetId ());
0 commit comments