prysm-pulse/beacon-chain/p2p/peer_decay.go
Jim McDonald 570efe3d04 Give peers a chance (#4268)
* Add decay function for peer badresponses count
* Activate peer decay in p2p
2019-12-12 14:34:28 +00:00

26 lines
481 B
Go

package p2p
import (
"context"
"time"
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers"
)
// starPeerDecay starts a loop that periodically decays the bad response count of peers, giving reformed peers a chance to rejoin
// the network.
// This runs every hour.
func startPeerDecay(ctx context.Context, peers *peers.Status) {
go (func() {
for {
select {
case <-ctx.Done():
return
default:
peers.Decay()
time.Sleep(1 * time.Hour)
}
}
})()
}