Merge pull request #1482 from cfromknecht/uniform-fee-update-timeout

htlcswitch/link: correct bias in fee update backoff
This commit is contained in:
Olaoluwa Osuntokun
2018-07-03 22:27:22 -05:00
committed by GitHub
3 changed files with 15 additions and 19 deletions

View File

@@ -995,12 +995,7 @@ out:
func (l *channelLink) randomFeeUpdateTimeout() time.Duration {
lower := int64(l.cfg.MinFeeUpdateTimeout)
upper := int64(l.cfg.MaxFeeUpdateTimeout)
rand := prand.Int63n(upper)
if rand < lower {
rand = lower
}
return time.Duration(rand)
return time.Duration(prand.Int63n(upper-lower) + lower)
}
// handleDownStreamPkt processes an HTLC packet sent from the downstream HTLC