mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-10 15:07:24 +00:00
The PEX reactor has a simple feedback control mechanism to decide how often to poll peers for peer address updates. The idea is to poll more frequently when knowledge of the network is less, and decrease frequency as knowledge grows. This change solves two problems: 1. It is possible in some cases we may poll a peer "too often" and get dropped by that peer for spamming. 2. The first successful peer update with any content resets the polling timer to a very long time (10m), meaning if we are unlucky in getting an incomplete reply while the network is small, we may not try again for a very long time. This may contribute to difficulties bootstrapping sync. The main change here is to only update the interval when new information is added to the system, and not (as before) whenever a request is sent out to a peer. The rate computation is essentially the same as before, although the code has been a bit simplified, and I consolidated some of the error handling so that we don't have to check in multiple places for the same conditions. Related changes: - Improve error diagnostics for too-soon and overflow conditions. - Clean up state handling in the poll interval computation. - Pin the minimum interval avert a chance of PEX spamming a peer.