diff --git a/waku/v2/discv5/discover.go b/waku/v2/discv5/discover.go index e723d20e..95bb8c78 100644 --- a/waku/v2/discv5/discover.go +++ b/waku/v2/discv5/discover.go @@ -379,9 +379,8 @@ func delayedHasNext(ctx context.Context, iterator enode.Iterator) bool { return true } -// Iterates over the nodes found via discv5 belonging to the node's current shard, and sends them to peerConnector -func (d *DiscoveryV5) peerLoop(ctx context.Context) error { - iterator, err := d.PeerIterator(FilterPredicate(func(n *enode.Node) bool { +func (d *DiscoveryV5) defaultPredicate() Predicate { + return FilterPredicate(func(n *enode.Node) bool { localRS, err := wenr.RelaySharding(d.localnode.Node().Record()) if err != nil { return false @@ -413,7 +412,12 @@ func (d *DiscoveryV5) peerLoop(ctx context.Context) error { } return false - })) + }) +} + +// Iterates over the nodes found via discv5 belonging to the node's current shard, and sends them to peerConnector +func (d *DiscoveryV5) peerLoop(ctx context.Context) error { + iterator, err := d.PeerIterator(d.defaultPredicate()) if err != nil { d.metrics.RecordError(iteratorFailure) return fmt.Errorf("obtaining iterator: %w", err) @@ -441,6 +445,20 @@ func (d *DiscoveryV5) peerLoop(ctx context.Context) error { } func (d *DiscoveryV5) runDiscoveryV5Loop(ctx context.Context) { + if len(d.config.Bootnodes) > 0 { + localRS, err := wenr.RelaySharding(d.localnode.Node().Record()) + if err == nil && localRS != nil { + iterator := d.defaultPredicate()(enode.IterNodes(d.config.Bootnodes)) + validBootCount := 0 + for iterator.Next() { + validBootCount++ + } + + if validBootCount == 0 { + d.log.Warn("no discv5 bootstrap nodes share this node configured shards") + } + } + } restartLoop: for {