MCPcopy Create free account
hub / github.com/ElementsProject/elements / CheckForStaleTipAndEvictPeers

Method CheckForStaleTipAndEvictPeers

src/net_processing.cpp:4430–4455  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4428}
4429
4430void PeerManagerImpl::CheckForStaleTipAndEvictPeers()
4431{
4432 LOCK(cs_main);
4433
4434 auto now{GetTime<std::chrono::seconds>()};
4435
4436 EvictExtraOutboundPeers(now);
4437
4438 if (now > m_stale_tip_check_time) {
4439 // Check whether our tip is stale, and if so, allow using an extra
4440 // outbound peer
4441 if (!fImporting && !fReindex && m_connman.GetNetworkActive() && m_connman.GetUseAddrmanOutgoing() && TipMayBeStale()) {
4442 LogPrintf("Potential stale tip detected, will try using extra outbound peer (last tip update: %d seconds ago)\n",
4443 count_seconds(now - m_last_tip_update.load()));
4444 m_connman.SetTryNewOutboundPeer(true);
4445 } else if (m_connman.GetTryNewOutboundPeer()) {
4446 m_connman.SetTryNewOutboundPeer(false);
4447 }
4448 m_stale_tip_check_time = now + STALE_CHECK_INTERVAL;
4449 }
4450
4451 if (!m_initial_sync_finished && CanDirectFetch()) {
4452 m_connman.StartExtraBlockRelayPeers();
4453 m_initial_sync_finished = true;
4454 }
4455}
4456
4457void PeerManagerImpl::MaybeSendPing(CNode& node_to, Peer& peer, std::chrono::microseconds now)
4458{

Callers 2

StartScheduledTasksMethod · 0.95
BOOST_AUTO_TEST_CASEFunction · 0.80

Calls 7

count_secondsFunction · 0.85
GetNetworkActiveMethod · 0.80
GetUseAddrmanOutgoingMethod · 0.80
SetTryNewOutboundPeerMethod · 0.80
GetTryNewOutboundPeerMethod · 0.80
loadMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64