Skip to content

Commit

Permalink
mark peer as bad (#6250)
Browse files Browse the repository at this point in the history
  • Loading branch information
nisdas committed Jun 14, 2020
1 parent f9d80e4 commit 933ab68
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions beacon-chain/sync/rpc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ func (r *Service) maintainPeerStatuses() {
runutil.RunEvery(r.ctx, interval, func() {
for _, pid := range r.p2p.Peers().Connected() {
go func(id peer.ID) {
if r.p2p.Peers().IsBad(id) {
if err := r.sendGoodByeAndDisconnect(r.ctx, codeGenericError, id); err != nil {
log.Errorf("Error when disconnecting with bad peer: %v", err)
}
return
}
// If the status hasn't been updated in the recent interval time.
lastUpdated, err := r.p2p.Peers().ChainStateLastUpdated(id)
if err != nil {
Expand All @@ -36,6 +42,7 @@ func (r *Service) maintainPeerStatuses() {
if roughtime.Now().After(lastUpdated.Add(interval)) {
if err := r.reValidatePeer(r.ctx, id); err != nil {
log.WithField("peer", id).WithError(err).Error("Failed to revalidate peer")
r.p2p.Peers().IncrementBadResponses(id)
}
}
}(pid)
Expand Down

0 comments on commit 933ab68

Please sign in to comment.