MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / StartScheduledTasks

Method StartScheduledTasks

src/net_processing.cpp:2054–2070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2052}
2053
2054void PeerManagerImpl::StartScheduledTasks(CScheduler& scheduler)
2055{
2056 // Stale tip checking and peer eviction are on two different timers, but we
2057 // don't want them to get out of sync due to drift in the scheduler, so we
2058 // combine them in one function and schedule at the quicker (peer-eviction)
2059 // timer.
2060 static_assert(EXTRA_PEER_CHECK_INTERVAL < STALE_CHECK_INTERVAL, "peer eviction timer should be less than stale tip check timer");
2061 scheduler.scheduleEvery([this] { this->CheckForStaleTipAndEvictPeers(); }, std::chrono::seconds{EXTRA_PEER_CHECK_INTERVAL});
2062
2063 // schedule next run for 10-15 minutes in the future
2064 const auto delta = 10min + FastRandomContext().randrange<std::chrono::milliseconds>(5min);
2065 scheduler.scheduleFromNow([&] { ReattemptInitialBroadcast(scheduler); }, delta);
2066
2067 if (m_opts.private_broadcast) {
2068 scheduler.scheduleFromNow([&] { ReattemptPrivateBroadcast(scheduler); }, 0min);
2069 }
2070}
2071
2072void PeerManagerImpl::ActiveTipChange(const CBlockIndex& new_tip, bool is_ibd)
2073{

Callers 1

AppInitMainFunction · 0.80

Calls 3

scheduleEveryMethod · 0.80
FastRandomContextClass · 0.70

Tested by

no test coverage detected