| 2052 | } |
| 2053 | |
| 2054 | void 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 | |
| 2072 | void PeerManagerImpl::ActiveTipChange(const CBlockIndex& new_tip, bool is_ibd) |
| 2073 | { |
no test coverage detected