Pass bootnodes to discovery

This commit is contained in:
Andrea Maria Piana 2022-12-09 18:09:06 +00:00 committed by RichΛrd
parent 685142e7b7
commit ebaf10601f
2 changed files with 14 additions and 6 deletions

View File

@ -8,9 +8,6 @@ import (
"sync" "sync"
"time" "time"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/ethereum/go-ethereum/p2p/nat"
"github.com/libp2p/go-libp2p/core/discovery" "github.com/libp2p/go-libp2p/core/discovery"
"github.com/libp2p/go-libp2p/core/host" "github.com/libp2p/go-libp2p/core/host"
"github.com/libp2p/go-libp2p/core/peer" "github.com/libp2p/go-libp2p/core/peer"
@ -18,6 +15,10 @@ import (
"github.com/waku-org/go-waku/logging" "github.com/waku-org/go-waku/logging"
"github.com/waku-org/go-waku/waku/v2/utils" "github.com/waku-org/go-waku/waku/v2/utils"
"go.uber.org/zap" "go.uber.org/zap"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/ethereum/go-ethereum/p2p/nat"
) )
type DiscoveryV5 struct { type DiscoveryV5 struct {
@ -208,7 +209,7 @@ func (d *DiscoveryV5) Start() error {
} }
func (d *DiscoveryV5) SetBootnodes(nodes []*enode.Node) error { func (d *DiscoveryV5) SetBootnodes(nodes []*enode.Node) error {
return d.listener.SetFallbackNodes(nodes) return d.listener.SetFallbackNodes(nodes)
} }
func (d *DiscoveryV5) Stop() { func (d *DiscoveryV5) Stop() {

View File

@ -8,11 +8,12 @@ import (
"sync" "sync"
"time" "time"
"github.com/libp2p/go-libp2p"
"go.uber.org/zap"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/enode"
"github.com/libp2p/go-libp2p"
"go.uber.org/zap"
pubsub "github.com/libp2p/go-libp2p-pubsub" pubsub "github.com/libp2p/go-libp2p-pubsub"
"github.com/libp2p/go-libp2p/core/event" "github.com/libp2p/go-libp2p/core/event"
@ -673,6 +674,12 @@ func (w *WakuNode) PeerStats() PeerStats {
return p return p
} }
// Set the bootnodes on discv5
func (w *WakuNode) SetDiscV5Bootnodes(nodes []*enode.Node) error {
w.opts.discV5bootnodes = nodes
return w.discoveryV5.SetBootnodes(nodes)
}
// Peers return the list of peers, addresses, protocols supported and connection status // Peers return the list of peers, addresses, protocols supported and connection status
func (w *WakuNode) Peers() ([]*Peer, error) { func (w *WakuNode) Peers() ([]*Peer, error) {
var peers []*Peer var peers []*Peer