Skip to content

Commit

Permalink
Merge branch 'develop' into eip6110
Browse files Browse the repository at this point in the history
  • Loading branch information
james-prysm authored Jun 27, 2024
2 parents f2be21f + 4becd7b commit 502a721
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions beacon-chain/p2p/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ package p2p

import (
"context"
"runtime"
"time"

"github.com/ethereum/go-ethereum/p2p/enode"
)

const backOffCounter = 50

// filterNodes wraps an iterator such that Next only returns nodes for which
// the 'check' function returns true. This custom implementation also
// checks for context deadlines so that in the event the parent context has
Expand All @@ -28,21 +24,13 @@ type filterIter struct {
// Next looks up for the next valid node according to our
// filter criteria.
func (f *filterIter) Next() bool {
lookupCounter := 0
for f.Iterator.Next() {
// Do not excessively perform lookups if we constantly receive non-viable peers.
if lookupCounter > backOffCounter {
lookupCounter = 0
runtime.Gosched()
time.Sleep(pollingPeriod)
}
if f.Context.Err() != nil {
return false
}
if f.check(f.Node()) {
return true
}
lookupCounter++
}
return false
}

0 comments on commit 502a721

Please sign in to comment.