MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / CheckForStaleTipAndEvictPeers

Method CheckForStaleTipAndEvictPeers

src/net_processing.cpp:3228–3248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3226}
3227
3228void PeerLogicValidation::CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams)
3229{
3230 if (connman == nullptr) return;
3231
3232 int64_t time_in_seconds = GetTime();
3233
3234 EvictExtraOutboundPeers(time_in_seconds);
3235
3236 if (time_in_seconds > m_stale_tip_check_time) {
3237 LOCK(cs_main);
3238 // Check whether our tip is stale, and if so, allow using an extra
3239 // outbound peer
3240 if (TipMayBeStale(consensusParams)) {
3241 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);
3242 connman->SetTryNewOutboundPeer(true);
3243 } else if (connman->GetTryNewOutboundPeer()) {
3244 connman->SetTryNewOutboundPeer(false);
3245 }
3246 m_stale_tip_check_time = time_in_seconds + STALE_CHECK_INTERVAL;
3247 }
3248}
3249
3250namespace {
3251class CompareInvMempoolOrder

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 3

GetTimeFunction · 0.85
SetTryNewOutboundPeerMethod · 0.80
GetTryNewOutboundPeerMethod · 0.80

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64