discovery

package
v0.0.0-...-e838296 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ENRToEnode

func ENRToEnode(enr string) (*enode.Node, error)

ENRToEnode converts an ENR string to an enode URL string.

Types

type ConnectablePeer

type ConnectablePeer struct {
	AddrInfo peer.AddrInfo
	Enode    *enode.Node
}

func DeriveDetailsFromNode

func DeriveDetailsFromNode(node *enode.Node) (*ConnectablePeer, error)

type DiscV4

type DiscV4 struct {
	// contains filtered or unexported fields
}

DiscV4 implements the discovery v4 protocol for finding Ethereum nodes.

func NewDiscV4

func NewDiscV4(_ context.Context, restart time.Duration, log logrus.FieldLogger) *DiscV4

NewDiscV4 creates a new discovery v4 instance.

func (*DiscV4) OnNodeRecord

func (d *DiscV4) OnNodeRecord(ctx context.Context, handler func(ctx context.Context, reason *enode.Node) error)

OnNodeRecord registers a handler to be called when new nodes are discovered.

func (*DiscV4) Start

func (d *DiscV4) Start(ctx context.Context) error

Start initializes and starts the discovery v4 protocol.

func (*DiscV4) Stop

func (d *DiscV4) Stop(_ context.Context) error

Stop gracefully shuts down the discovery v4 protocol.

func (*DiscV4) UpdateBootNodes

func (d *DiscV4) UpdateBootNodes(bootNodes []string) error

UpdateBootNodes updates the list of bootstrap nodes used for discovery.

type DiscV5

type DiscV5 struct {
	// contains filtered or unexported fields
}

DiscV5 implements the discovery v5 protocol for finding Ethereum nodes.

func NewDiscV5

func NewDiscV5(_ context.Context, restart time.Duration, log logrus.FieldLogger) *DiscV5

NewDiscV5 creates a new discovery v5 instance.

func (*DiscV5) OnNodeRecord

func (d *DiscV5) OnNodeRecord(ctx context.Context, handler func(ctx context.Context, reason *enode.Node) error)

OnNodeRecord registers a handler to be called when new nodes are discovered.

func (*DiscV5) Start

func (d *DiscV5) Start(ctx context.Context) error

Start initializes and starts the discovery v5 protocol.

func (*DiscV5) Stop

func (d *DiscV5) Stop(_ context.Context) error

Stop gracefully shuts down the discovery v5 protocol.

func (*DiscV5) UpdateBootNodes

func (d *DiscV5) UpdateBootNodes(bootNodes []string) error

UpdateBootNodes updates the list of bootstrap nodes used for discovery.

type ListenerV4

type ListenerV4 struct {
	// contains filtered or unexported fields
}

ListenerV4 manages the UDP connection and discovery protocol instance.

func (*ListenerV4) Close

func (l *ListenerV4) Close() error

Close shuts down the listener and releases all resources.

func (*ListenerV4) GetLocalNodeID

func (l *ListenerV4) GetLocalNodeID() *enode.ID

GetLocalNodeID returns the local node ID in a thread-safe manner.

type ListenerV5

type ListenerV5 struct {
	// contains filtered or unexported fields
}

ListenerV5 manages the UDP connection and discovery protocol instance.

func (*ListenerV5) Close

func (l *ListenerV5) Close() error

Close shuts down the listener and releases all resources.

func (*ListenerV5) GetLocalNodeID

func (l *ListenerV5) GetLocalNodeID() *enode.ID

GetLocalNodeID returns the local node ID in a thread-safe manner.

type Manual

type Manual struct {
	// contains filtered or unexported fields
}

Manual is a NodeFinder that allows you to manually add nodes to the discovery pool.

func (*Manual) AddNode

func (m *Manual) AddNode(ctx context.Context, node *enode.Node) error

func (*Manual) OnNodeRecord

func (m *Manual) OnNodeRecord(ctx context.Context, handler func(ctx context.Context, node *enode.Node) error)

func (*Manual) Start

func (m *Manual) Start(ctx context.Context) error

func (*Manual) Stop

func (m *Manual) Stop(ctx context.Context) error

type NodeFinder

type NodeFinder interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context) error
	OnNodeRecord(ctx context.Context, handler func(ctx context.Context, node *enode.Node) error)
}

Jump to

Keyboard shortcuts

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