@@ -427,14 +427,14 @@ class PeerManagerImpl final : public PeerManager
427
427
* Returns false, still setting pit, if the block was already in flight from the same peer
428
428
* pit will only be valid as long as the same cs_main lock is being held
429
429
*/
430
- bool MarkBlockAsInFlight (CTxMemPool& mempool, NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr , std::list<QueuedBlock>::iterator** pit = nullptr ) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
430
+ bool MarkBlockAsInFlight (NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr , std::list<QueuedBlock>::iterator** pit = nullptr ) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
431
431
432
- bool TipMayBeStale (const Consensus::Params &consensusParams ) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
432
+ bool TipMayBeStale () EXCLUSIVE_LOCKS_REQUIRED(cs_main);
433
433
434
434
/* * Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has
435
435
* at most count entries.
436
436
*/
437
- void FindNextBlocksToDownload (NodeId nodeid, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller, const Consensus::Params& consensusParams ) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
437
+ void FindNextBlocksToDownload (NodeId nodeid, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
438
438
439
439
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > mapBlocksInFlight GUARDED_BY (cs_main);
440
440
@@ -655,7 +655,7 @@ bool PeerManagerImpl::MarkBlockAsReceived(const uint256& hash) EXCLUSIVE_LOCKS_R
655
655
return false ;
656
656
}
657
657
658
- bool PeerManagerImpl::MarkBlockAsInFlight (CTxMemPool& mempool, NodeId nodeid, const uint256& hash, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
658
+ bool PeerManagerImpl::MarkBlockAsInFlight (NodeId nodeid, const uint256& hash, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
659
659
{
660
660
CNodeState *state = State (nodeid);
661
661
assert (state != nullptr );
@@ -673,7 +673,7 @@ bool PeerManagerImpl::MarkBlockAsInFlight(CTxMemPool& mempool, NodeId nodeid, co
673
673
MarkBlockAsReceived (hash);
674
674
675
675
std::list<QueuedBlock>::iterator it = state->vBlocksInFlight .insert (state->vBlocksInFlight .end (),
676
- {hash, pindex, pindex != nullptr , std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock (&mempool ) : nullptr )});
676
+ {hash, pindex, pindex != nullptr , std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock (&m_mempool ) : nullptr )});
677
677
state->nBlocksInFlight ++;
678
678
state->nBlocksInFlightValidHeaders += it->fValidatedHeaders ;
679
679
if (state->nBlocksInFlight == 1 ) {
@@ -769,9 +769,10 @@ static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman& connma
769
769
}
770
770
}
771
771
772
- bool PeerManagerImpl::TipMayBeStale (const Consensus::Params &consensusParams ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
772
+ bool PeerManagerImpl::TipMayBeStale () EXCLUSIVE_LOCKS_REQUIRED(cs_main)
773
773
{
774
774
AssertLockHeld (cs_main);
775
+ const Consensus::Params& consensusParams = m_chainparams.GetConsensus ();
775
776
if (m_last_tip_update == 0 ) {
776
777
m_last_tip_update = GetTime ();
777
778
}
@@ -792,7 +793,7 @@ static bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex) EXCLUSIV
792
793
return false ;
793
794
}
794
795
795
- void PeerManagerImpl::FindNextBlocksToDownload (NodeId nodeid, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller, const Consensus::Params& consensusParams ) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
796
+ void PeerManagerImpl::FindNextBlocksToDownload (NodeId nodeid, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
796
797
{
797
798
if (count == 0 )
798
799
return ;
@@ -821,6 +822,7 @@ void PeerManagerImpl::FindNextBlocksToDownload(NodeId nodeid, unsigned int count
821
822
if (state->pindexLastCommonBlock == state->pindexBestKnownBlock )
822
823
return ;
823
824
825
+ const Consensus::Params& consensusParams = m_chainparams.GetConsensus ();
824
826
std::vector<const CBlockIndex*> vToFetch;
825
827
const CBlockIndex *pindexWalk = state->pindexLastCommonBlock ;
826
828
// Never fetch further than the best block we know the peer has, or more than BLOCK_DOWNLOAD_WINDOW + 1 beyond the last
@@ -2119,7 +2121,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
2119
2121
}
2120
2122
uint32_t nFetchFlags = GetFetchFlags (pfrom);
2121
2123
vGetData.push_back (CInv (MSG_BLOCK | nFetchFlags, pindex->GetBlockHash ()));
2122
- MarkBlockAsInFlight (m_mempool, pfrom.GetId (), pindex->GetBlockHash (), pindex);
2124
+ MarkBlockAsInFlight (pfrom.GetId (), pindex->GetBlockHash (), pindex);
2123
2125
LogPrint (BCLog::NET, " Requesting block %s from peer=%d\n " ,
2124
2126
pindex->GetBlockHash ().ToString (), pfrom.GetId ());
2125
2127
}
@@ -3468,7 +3470,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3468
3470
if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) ||
3469
3471
(fAlreadyInFlight && blockInFlightIt->second .first == pfrom.GetId ())) {
3470
3472
std::list<QueuedBlock>::iterator* queuedBlockIt = nullptr ;
3471
- if (!MarkBlockAsInFlight (m_mempool, pfrom.GetId (), pindex->GetBlockHash (), pindex, &queuedBlockIt)) {
3473
+ if (!MarkBlockAsInFlight (pfrom.GetId (), pindex->GetBlockHash (), pindex, &queuedBlockIt)) {
3472
3474
if (!(*queuedBlockIt)->partialBlock )
3473
3475
(*queuedBlockIt)->partialBlock .reset (new PartiallyDownloadedBlock (&m_mempool));
3474
3476
else {
@@ -4265,7 +4267,7 @@ void PeerManagerImpl::CheckForStaleTipAndEvictPeers()
4265
4267
if (time_in_seconds > m_stale_tip_check_time) {
4266
4268
// Check whether our tip is stale, and if so, allow using an extra
4267
4269
// outbound peer
4268
- if (!fImporting && !fReindex && m_connman.GetNetworkActive () && m_connman.GetUseAddrmanOutgoing () && TipMayBeStale (m_chainparams. GetConsensus () )) {
4270
+ if (!fImporting && !fReindex && m_connman.GetNetworkActive () && m_connman.GetUseAddrmanOutgoing () && TipMayBeStale ()) {
4269
4271
LogPrintf (" Potential stale tip detected, will try using extra outbound peer (last tip update: %d seconds ago)\n " , time_in_seconds - m_last_tip_update);
4270
4272
m_connman.SetTryNewOutboundPeer (true );
4271
4273
} else if (m_connman.GetTryNewOutboundPeer ()) {
@@ -4793,11 +4795,11 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4793
4795
if (!pto->fClient && ((fFetch && !pto->m_limited_node ) || !::ChainstateActive ().IsInitialBlockDownload ()) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
4794
4796
std::vector<const CBlockIndex*> vToDownload;
4795
4797
NodeId staller = -1 ;
4796
- FindNextBlocksToDownload (pto->GetId (), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight , vToDownload, staller, consensusParams );
4798
+ FindNextBlocksToDownload (pto->GetId (), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight , vToDownload, staller);
4797
4799
for (const CBlockIndex *pindex : vToDownload) {
4798
4800
uint32_t nFetchFlags = GetFetchFlags (*pto);
4799
4801
vGetData.push_back (CInv (MSG_BLOCK | nFetchFlags, pindex->GetBlockHash ()));
4800
- MarkBlockAsInFlight (m_mempool, pto->GetId (), pindex->GetBlockHash (), pindex);
4802
+ MarkBlockAsInFlight (pto->GetId (), pindex->GetBlockHash (), pindex);
4801
4803
LogPrint (BCLog::NET, " Requesting block %s (%d) peer=%d\n " , pindex->GetBlockHash ().ToString (),
4802
4804
pindex->nHeight , pto->GetId ());
4803
4805
}
0 commit comments