Documentation ¶
Index ¶
- Variables
- type DiscoveryV5
- func (d *DiscoveryV5) Iterate(ctx context.Context, iterator enode.Iterator, ...)
- func (d *DiscoveryV5) Node() *enode.Node
- func (d *DiscoveryV5) PeerIterator(predicate ...Predicate) (enode.Iterator, error)
- func (d *DiscoveryV5) SetBootnodes(nodes []*enode.Node) error
- func (d *DiscoveryV5) SetHost(h host.Host)
- func (d *DiscoveryV5) Start(ctx context.Context) error
- func (d *DiscoveryV5) Stop()
- type DiscoveryV5Option
- func DefaultOptions() []DiscoveryV5Option
- func WithAdvertiseAddr(addr []multiaddr.Multiaddr) DiscoveryV5Option
- func WithAutoFindPeers(find bool) DiscoveryV5Option
- func WithAutoUpdate(autoUpdate bool) DiscoveryV5Option
- func WithBootnodes(bootnodes []*enode.Node) DiscoveryV5Option
- func WithPredicate(predicate func(*enode.Node) bool) DiscoveryV5Option
- func WithUDPPort(port uint) DiscoveryV5Option
- type Metrics
- type PeerConnector
- type Predicate
Constants ¶
This section is empty.
Variables ¶
var ErrNoDiscV5Listener = errors.New("no discv5 listener")
Functions ¶
This section is empty.
Types ¶
type DiscoveryV5 ¶
type DiscoveryV5 struct { NAT nat.Interface *peermanager.CommonDiscoveryService // contains filtered or unexported fields }
func NewDiscoveryV5 ¶
func NewDiscoveryV5(priv *ecdsa.PrivateKey, localnode *enode.LocalNode, peerConnector PeerConnector, reg prometheus.Registerer, log *zap.Logger, opts ...DiscoveryV5Option) (*DiscoveryV5, error)
NewDiscoveryV5 returns a new instance of a DiscoveryV5 struct
func (*DiscoveryV5) Node ¶
func (d *DiscoveryV5) Node() *enode.Node
func (*DiscoveryV5) PeerIterator ¶ added in v0.8.0
func (d *DiscoveryV5) PeerIterator(predicate ...Predicate) (enode.Iterator, error)
PeerIterator gets random nodes from DHT via discv5 listener. Used for caching enr address in peerExchange Used for connecting to peers in discovery_connector
func (*DiscoveryV5) SetBootnodes ¶
func (d *DiscoveryV5) SetBootnodes(nodes []*enode.Node) error
SetBootnodes is used to setup the bootstrap nodes to use for discovering new peers
func (*DiscoveryV5) SetHost ¶ added in v0.6.0
func (d *DiscoveryV5) SetHost(h host.Host)
Sets the host to be able to mount or consume a protocol
func (*DiscoveryV5) Start ¶
func (d *DiscoveryV5) Start(ctx context.Context) error
only works if the discovery v5 hasn't been started yet.
func (*DiscoveryV5) Stop ¶
func (d *DiscoveryV5) Stop()
Stop is a function that stops the execution of DiscV5. only works if the discovery v5 is in running state so we can assume that cancel method is set
type DiscoveryV5Option ¶
type DiscoveryV5Option func(*discV5Parameters)
func DefaultOptions ¶
func DefaultOptions() []DiscoveryV5Option
DefaultOptions contains the default list of options used when setting up DiscoveryV5
func WithAdvertiseAddr ¶
func WithAdvertiseAddr(addr []multiaddr.Multiaddr) DiscoveryV5Option
func WithAutoFindPeers ¶ added in v0.7.0
func WithAutoFindPeers(find bool) DiscoveryV5Option
func WithAutoUpdate ¶
func WithAutoUpdate(autoUpdate bool) DiscoveryV5Option
func WithBootnodes ¶
func WithBootnodes(bootnodes []*enode.Node) DiscoveryV5Option
WithBootnodes is an option used to specify the bootstrap nodes to use with DiscV5
func WithPredicate ¶ added in v0.7.0
func WithPredicate(predicate func(*enode.Node) bool) DiscoveryV5Option
func WithUDPPort ¶
func WithUDPPort(port uint) DiscoveryV5Option
type Metrics ¶ added in v0.8.0
type Metrics interface {
RecordError(err metricsErrCategory)
}
Metrics exposes the functions required to update prometheus metrics for discv5 protocol
type PeerConnector ¶ added in v0.4.0
type PeerConnector interface {
Subscribe(context.Context, <-chan peermanager.PeerData)
}
PeerConnector will subscribe to a channel containing the information for all peers found by this discovery protocol
type Predicate ¶ added in v0.8.0
Predicate is a function that is applied to an iterator to filter the nodes to be retrieved according to some logic
func FilterCapabilities ¶ added in v0.8.0
func FilterCapabilities(flags wenr.WakuEnrBitfield) Predicate
FilterCapabilities creates a Predicate to filter nodes that support specific protocols
func FilterPredicate ¶ added in v0.8.0
FilterPredicate is to create a Predicate using a custom function
func FilterShard ¶ added in v0.8.0
FilterShard creates a Predicate that filters nodes that belong to a specific shard