Crate reth_discv4

Source
Expand description

Discovery v4 implementation: https://github.com/ethereum/devp2p/blob/master/discv4.md

Discv4 employs a kademlia-like routing table to store and manage discovered peers and topics. The protocol allows for external IP discovery in NAT environments through regular PING/PONG’s with discovered nodes. Nodes return the external IP address that they have received and a simple majority is chosen as our external IP address. If an external IP address is updated, this is produced as an event to notify the swarm (if one is used for this behaviour).

This implementation consists of a Discv4 and Discv4Service pair. The service manages the state and drives the UDP socket. The (optional) Discv4 serves as the frontend to interact with the service via a channel. Whenever the underlying table changes service produces a DiscoveryUpdate that listeners will receive.

§Feature Flags

  • serde (default): Enable serde support
  • test-utils: Export utilities for testing

Modules§

error
Error types that can occur in this crate.
proto
Discovery v4 protocol implementation.
test_utilstest-utils
Mock discovery support

Structs§

Discv4
The Discv4 frontend.
Discv4Config
Configuration parameters that define the performance of the discovery network.
Discv4ConfigBuilder
Builder type for Discv4Config
Discv4Service
Manages discv4 peer discovery over UDP.
NodeRecord
Represents an ENR in discovery.

Enums§

DiscoveryUpdate
Represents node related updates state changes in the underlying node table
Discv4Event
The Event type the Service stream produces.
NatResolver
reexport to get public ip. All builtin resolvers.

Constants§

DEFAULT_DISCOVERY_ADDR
The default address for discv4 via UDP
DEFAULT_DISCOVERY_ADDRESS
The default address for discv4 via UDP: “0.0.0.0:30303”
DEFAULT_DISCOVERY_PORT
The default port for discv4 via UDP

Functions§

external_ip
reexport to get public ip. Attempts to produce an IP address with all builtin resolvers (best effort).