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 supporttest-utils
: Export utilities for testing
Modules§
- error
- Error types that can occur in this crate.
- proto
- Discovery v4 protocol implementation.
- test_
utils test-utils
- Mock discovery support
Structs§
- Discv4
- The Discv4 frontend.
- Discv4
Config - Configuration parameters that define the performance of the discovery network.
- Discv4
Config Builder - Builder type for
Discv4Config
- Discv4
Service - Manages discv4 peer discovery over UDP.
- Node
Record - Represents an ENR in discovery.
Enums§
- Discovery
Update - Represents node related updates state changes in the underlying node table
- Discv4
Event - 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).