re annouce with exponential back-off

This commit is contained in:
2024-07-14 12:38:00 +02:00
parent bc5599a230
commit 74414d0999
6 changed files with 146 additions and 16 deletions

View File

@@ -25,6 +25,25 @@ bool FT1ChunkSHA1Cache::haveChunk(const SHA1Digest& hash) const {
return false;
}
void ReAnnounceTimer::set(const float new_timer) {
timer = new_timer;
last_max = new_timer;
}
void ReAnnounceTimer::reset(void) {
if (last_max <= 0.01f) {
last_max = 1.f;
}
last_max *= 2.f;
timer = last_max;
}
void ReAnnounceTimer::lower(void) {
timer *= 0.1f;
last_max *= 0.1f;
}
void TransferStatsTally::Peer::trimSent(const float time_now) {
while (recently_sent.size() > 4 && time_now - recently_sent.front().time_point > 1.f) {
recently_sent.pop_front();