Reduce PING frequency and simplify logic:

The existing code issues a PING to each peer every 8 seconds. While
frequent PINGs allow us to estimate a peer's latency with a high
degree of accuracy, this "inter-server polka dance" is inefficient
and not useful. This commit, if merged, reduces the PING frequency
to once every 60 seconds.

Additionally, this commit simplifies the PING handling logic and
merges the code used to check and disconnect peers which fail to
track the network directly into the timer callback.
This commit is contained in:
Nik Bougalis
2020-09-10 23:52:13 -07:00
parent cba6b4a749
commit 8c386ae07e
6 changed files with 56 additions and 133 deletions

View File

@@ -100,9 +100,6 @@ OverlayImpl::Timer::on_timer(error_code ec)
overlay_.sendEndpoints();
overlay_.autoConnect();
if ((++overlay_.timer_count_ % Tuning::checkSeconds) == 0)
overlay_.check();
if ((overlay_.timer_count_ % Tuning::checkIdlePeers) == 0)
overlay_.deleteIdlePeers();
@@ -1187,12 +1184,6 @@ OverlayImpl::checkTracking(std::uint32_t index)
[index](std::shared_ptr<PeerImp>&& sp) { sp->checkTracking(index); });
}
void
OverlayImpl::check()
{
for_each([](std::shared_ptr<PeerImp>&& sp) { sp->check(); });
}
std::shared_ptr<Peer>
OverlayImpl::findPeerByShortID(Peer::id_t const& id) const
{