From 955344bf9b7a508e9f4a773d764b6070c064cdae Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 3 Sep 2020 00:40:46 +0300 Subject: [PATCH] tweak probability threshold --- peer_gater.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/peer_gater.go b/peer_gater.go index 5697382..322d814 100644 --- a/peer_gater.go +++ b/peer_gater.go @@ -165,12 +165,12 @@ func (pg *peerGater) AcceptFrom(p peer.ID) AcceptStatus { } // we make a randomized decision based on the goodput of the peer - goodput := st.deliver / total - if rand.Float64() < goodput { + threshold := (1 + st.deliver) / (1 + total) + if rand.Float64() < threshold { return AcceptAll } - log.Debugf("throttling peer %s with goodput %f", p, goodput) + log.Debugf("throttling peer %s with threshold %f", p, threshold) return AcceptControl }