Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,534 Lines • ▼ Show 20 Lines | PeerManager::PeerManager(const CChainParams &chainparams, CConnman &connman, | ||||
// Stale tip checking and peer eviction are on two different timers, but we | // Stale tip checking and peer eviction are on two different timers, but we | ||||
// don't want them to get out of sync due to drift in the scheduler, so we | // don't want them to get out of sync due to drift in the scheduler, so we | ||||
// combine them in one function and schedule at the quicker (peer-eviction) | // combine them in one function and schedule at the quicker (peer-eviction) | ||||
// timer. | // timer. | ||||
static_assert( | static_assert( | ||||
EXTRA_PEER_CHECK_INTERVAL < STALE_CHECK_INTERVAL, | EXTRA_PEER_CHECK_INTERVAL < STALE_CHECK_INTERVAL, | ||||
"peer eviction timer should be less than stale tip check timer"); | "peer eviction timer should be less than stale tip check timer"); | ||||
scheduler.scheduleEvery( | scheduler.scheduleEvery( | ||||
[this, &consensusParams]() { | [this, consensusParams]() { | ||||
this->CheckForStaleTipAndEvictPeers(consensusParams); | this->CheckForStaleTipAndEvictPeers(consensusParams); | ||||
return true; | return true; | ||||
}, | }, | ||||
std::chrono::seconds{EXTRA_PEER_CHECK_INTERVAL}); | std::chrono::seconds{EXTRA_PEER_CHECK_INTERVAL}); | ||||
// schedule next run for 10-15 minutes in the future | // schedule next run for 10-15 minutes in the future | ||||
const std::chrono::milliseconds delta = | const std::chrono::milliseconds delta = | ||||
std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5}); | std::chrono::minutes{10} + GetRandMillis(std::chrono::minutes{5}); | ||||
▲ Show 20 Lines • Show All 4,381 Lines • Show Last 20 Lines |