@@ -472,7 +472,7 @@ class PeerManagerImpl final : public PeerManager
472
472
* Returns false, still setting pit, if the block was already in flight from the same peer
473
473
* pit will only be valid as long as the same cs_main lock is being held
474
474
*/
475
- bool MarkBlockAsInFlight (NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr , std::list<QueuedBlock>::iterator** pit = nullptr ) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
475
+ bool MarkBlockAsInFlight (NodeId nodeid, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit = nullptr ) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
476
476
477
477
bool TipMayBeStale () EXCLUSIVE_LOCKS_REQUIRED(cs_main);
478
478
@@ -782,8 +782,11 @@ bool PeerManagerImpl::MarkBlockAsReceived(const uint256& hash)
782
782
return false ;
783
783
}
784
784
785
- bool PeerManagerImpl::MarkBlockAsInFlight (NodeId nodeid, const uint256& hash, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit)
785
+ bool PeerManagerImpl::MarkBlockAsInFlight (NodeId nodeid, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit)
786
786
{
787
+ assert (pindex);
788
+ const uint256& hash{pindex->GetBlockHash ()};
789
+
787
790
CNodeState *state = State (nodeid);
788
791
assert (state != nullptr );
789
792
@@ -807,7 +810,7 @@ bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, co
807
810
// We're starting a block download (batch) from this peer.
808
811
state->m_downloading_since = GetTime<std::chrono::microseconds>();
809
812
}
810
- if (state->nBlocksInFlightValidHeaders == 1 && pindex != nullptr ) {
813
+ if (state->nBlocksInFlightValidHeaders == 1 ) {
811
814
nPeersWithValidatedDownloads++;
812
815
}
813
816
itInFlight = mapBlocksInFlight.insert (std::make_pair (hash, std::make_pair (nodeid, it))).first ;
@@ -2081,7 +2084,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
2081
2084
}
2082
2085
uint32_t nFetchFlags = GetFetchFlags (pfrom);
2083
2086
vGetData.push_back (CInv (MSG_BLOCK | nFetchFlags, pindex->GetBlockHash ()));
2084
- MarkBlockAsInFlight (pfrom.GetId (), pindex-> GetBlockHash (), pindex );
2087
+ MarkBlockAsInFlight (pfrom.GetId (), pindex);
2085
2088
LogPrint (BCLog::NET, " Requesting block %s from peer=%d\n " ,
2086
2089
pindex->GetBlockHash ().ToString (), pfrom.GetId ());
2087
2090
}
@@ -3384,7 +3387,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3384
3387
if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) ||
3385
3388
(fAlreadyInFlight && blockInFlightIt->second .first == pfrom.GetId ())) {
3386
3389
std::list<QueuedBlock>::iterator* queuedBlockIt = nullptr ;
3387
- if (!MarkBlockAsInFlight (pfrom.GetId (), pindex-> GetBlockHash (), pindex , &queuedBlockIt)) {
3390
+ if (!MarkBlockAsInFlight (pfrom.GetId (), pindex, &queuedBlockIt)) {
3388
3391
if (!(*queuedBlockIt)->partialBlock )
3389
3392
(*queuedBlockIt)->partialBlock .reset (new PartiallyDownloadedBlock (&m_mempool));
3390
3393
else {
@@ -4767,7 +4770,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4767
4770
for (const CBlockIndex *pindex : vToDownload) {
4768
4771
uint32_t nFetchFlags = GetFetchFlags (*pto);
4769
4772
vGetData.push_back (CInv (MSG_BLOCK | nFetchFlags, pindex->GetBlockHash ()));
4770
- MarkBlockAsInFlight (pto->GetId (), pindex-> GetBlockHash (), pindex );
4773
+ MarkBlockAsInFlight (pto->GetId (), pindex);
4771
4774
LogPrint (BCLog::NET, " Requesting block %s (%d) peer=%d\n " , pindex->GetBlockHash ().ToString (),
4772
4775
pindex->nHeight , pto->GetId ());
4773
4776
}
0 commit comments