mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Merge #14027: Skip stale tip checking if outbound connections are off or if reindexing.
66b3fc5437 Skip stale tip checking if outbound connections are off or if reindexing. (Gregory Maxwell)
Pull request description:
I got tired of the pointless stale tip notices in reindex and on nodes with connections disabled.
Tree-SHA512: eb07d9c5c787ae6dea02cdd1d67a48a36a30adc5ccc74d6f1c0c7364d404dc8848b35d2b8daf5283f7c8f36f1a3c463aacb190d70a22d1fe796a301bb1f03228
This commit is contained in:
@@ -3144,8 +3144,6 @@ void PeerLogicValidation::EvictExtraOutboundPeers(int64_t time_in_seconds)
|
||||
NodeId worst_peer = -1;
|
||||
int64_t oldest_block_announcement = std::numeric_limits<int64_t>::max();
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
connman->ForEachNode([&](CNode* pnode) {
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
@@ -3193,6 +3191,8 @@ void PeerLogicValidation::EvictExtraOutboundPeers(int64_t time_in_seconds)
|
||||
|
||||
void PeerLogicValidation::CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams)
|
||||
{
|
||||
LOCK(cs_main);
|
||||
|
||||
if (connman == nullptr) return;
|
||||
|
||||
int64_t time_in_seconds = GetTime();
|
||||
@@ -3200,10 +3200,9 @@ void PeerLogicValidation::CheckForStaleTipAndEvictPeers(const Consensus::Params
|
||||
EvictExtraOutboundPeers(time_in_seconds);
|
||||
|
||||
if (time_in_seconds > m_stale_tip_check_time) {
|
||||
LOCK(cs_main);
|
||||
// Check whether our tip is stale, and if so, allow using an extra
|
||||
// outbound peer
|
||||
if (TipMayBeStale(consensusParams)) {
|
||||
if (!fImporting && !fReindex && connman->GetNetworkActive() && connman->GetUseAddrmanOutgoing() && TipMayBeStale(consensusParams)) {
|
||||
LogPrintf("Potential stale tip detected, will try using extra outbound peer (last tip update: %d seconds ago)\n", time_in_seconds - g_last_tip_update);
|
||||
connman->SetTryNewOutboundPeer(true);
|
||||
} else if (connman->GetTryNewOutboundPeer()) {
|
||||
|
||||
Reference in New Issue
Block a user