mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 14:16:44 +00:00
p2p/enode: don't pass error in AsyncFilter check
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
a80c579d7f
commit
33660b37a1
2 changed files with 7 additions and 4 deletions
|
|
@ -505,9 +505,12 @@ func (s *Ethereum) setupDiscovery() error {
|
||||||
// Add DHT nodes from discv4.
|
// Add DHT nodes from discv4.
|
||||||
if s.p2pServer.DiscoveryV4() != nil {
|
if s.p2pServer.DiscoveryV4() != nil {
|
||||||
iter := s.p2pServer.DiscoveryV4().RandomNodes()
|
iter := s.p2pServer.DiscoveryV4().RandomNodes()
|
||||||
resolverFunc := func(ctx context.Context, enr *enode.Node) (*enode.Node, error) {
|
resolverFunc := func(ctx context.Context, enr *enode.Node) *enode.Node {
|
||||||
// RequestENR does not yet support context. It will simply time out.
|
// RequestENR does not yet support context. It will simply time out.
|
||||||
return s.p2pServer.DiscoveryV4().RequestENR(enr)
|
// If the ENR can't be resolved, RequestENR will return nil. We don't
|
||||||
|
// care about the specific error here, so we ignore it.
|
||||||
|
nn, _ := s.p2pServer.DiscoveryV4().RequestENR(enr)
|
||||||
|
return nn
|
||||||
}
|
}
|
||||||
iter = enode.AsyncFilter(iter, resolverFunc, maxParallelENRRequests)
|
iter = enode.AsyncFilter(iter, resolverFunc, maxParallelENRRequests)
|
||||||
iter = enode.Filter(iter, eth.NewNodeFilter(s.blockchain))
|
iter = enode.Filter(iter, eth.NewNodeFilter(s.blockchain))
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ type AsyncFilterIter struct {
|
||||||
cancel context.CancelFunc
|
cancel context.CancelFunc
|
||||||
closeOnce sync.Once
|
closeOnce sync.Once
|
||||||
}
|
}
|
||||||
type AsyncFilterFunc func(context.Context, *Node) (*Node, error)
|
type AsyncFilterFunc func(context.Context, *Node) *Node
|
||||||
|
|
||||||
// AsyncFilter creates an iterator which checks nodes in parallel.
|
// AsyncFilter creates an iterator which checks nodes in parallel.
|
||||||
func AsyncFilter(it Iterator, check AsyncFilterFunc, workers int) Iterator {
|
func AsyncFilter(it Iterator, check AsyncFilterFunc, workers int) Iterator {
|
||||||
|
|
@ -192,7 +192,7 @@ func AsyncFilter(it Iterator, check AsyncFilterFunc, workers int) Iterator {
|
||||||
<-f.slots
|
<-f.slots
|
||||||
// check the node async, in a separate goroutine
|
// check the node async, in a separate goroutine
|
||||||
go func() {
|
go func() {
|
||||||
if nn, err := check(ctx, n); err == nil {
|
if nn := check(ctx, n); nn != nil {
|
||||||
select {
|
select {
|
||||||
case f.passed <- nn:
|
case f.passed <- nn:
|
||||||
case <-ctx.Done(): // bale out if downstream is already closed and not calling Next
|
case <-ctx.Done(): // bale out if downstream is already closed and not calling Next
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue