chanfitness: cool down flap count for rate limiting
Since we store all-time flap count for a peer, we add a cooldown factor which will discount poor flap counts in the past. This is only applied to peers that have not flapped for at least a cooldown period, so that we do not downgrade our rate limiting for badly behaved peers.
This commit is contained in:
4 files changed
+155
-5
No files matched your search
@@ -117,6 +117,16 @@ func newChannelInfo(openedAt time.Time) *channelInfo {
|
||||
func (p *peerLog) onlineEvent(online bool) {
|
||||
eventTime := p.clock.Now()
|
||||
|
||||
// If we have a non-nil last flap time, potentially apply a cooldown
|
||||
// factor to the peer's flap count before we rate limit it. This allows
|
||||
// us to decrease the penalty for historical flaps over time, provided
|
||||
// the peer has not flapped for a while.
|
||||
if p.lastFlap != nil {
|
||||
p.flapCount = cooldownFlapCount(
|
||||
p.clock.Now(), p.flapCount, *p.lastFlap,
|
||||
)
|
||||
}
|
||||
|
||||
// Record flap count information and online state regardless of whether
|
||||
// we have any channels open with this peer.
|
||||
p.flapCount++
|
||||
|
||||
Reference in new issue
Block a user