tweak probability threshold

This commit is contained in:
vyzo 2020-09-03 00:40:46 +03:00
parent ff1b1a9772
commit 955344bf9b
1 changed files with 3 additions and 3 deletions

View File

@ -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
}