discv5

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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) Iterate added in v0.7.0

func (d *DiscoveryV5) Iterate(ctx context.Context, iterator enode.Iterator, onNode func(*enode.Node, peer.AddrInfo) error)

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

type Predicate func(enode.Iterator) enode.Iterator

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

func FilterPredicate(predicate func(*enode.Node) bool) Predicate

FilterPredicate is to create a Predicate using a custom function

func FilterShard added in v0.8.0

func FilterShard(cluster, index uint16) Predicate

FilterShard creates a Predicate that filters nodes that belong to a specific shard

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL