Documentation ¶
Overview ¶
Package discover implements the Node Discovery Protocol.
The Node Discovery protocol provides a way to find RLPx nodes that can be connected to. It uses a Kademlia-like protocol to maintain a distributed database of the IDs and endpoints of all listening nodes.
Index ¶
- type Config
- type ReadPacket
- type Table
- type UDPConn
- type UDPv5
- func (t *UDPv5) AddRecentNode(n *enode.Node, at time.Time, liveness uint)
- func (t *UDPv5) AllNodes() []*enode.Node
- func (t *UDPv5) Close()
- func (t *UDPv5) LocalNode() *enode.LocalNode
- func (t *UDPv5) Lookup(target enode.ID) []*enode.Node
- func (t *UDPv5) Ping(n *enode.Node) error
- func (t *UDPv5) PingSeq(n *enode.Node) (uint64, error)
- func (t *UDPv5) RandomNodes() enode.Iterator
- func (t *UDPv5) RequestENR(n *enode.Node) (*enode.Node, error)
- func (t *UDPv5) Resolve(n *enode.Node) *enode.Node
- func (t *UDPv5) SeeNode(n *enode.Node, at time.Time, liveness uint)
- func (t *UDPv5) Self() *enode.Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // These settings are required and configure the UDP listener: PrivateKey *ecdsa.PrivateKey // CATDOG HACK Revalidator func(node2 *enode.Node) (uint64, error) OnSeen func(n *enode.Node, at time.Time, liveness uint) // These settings are optional: NetRestrict *netutil.Netlist // network whitelist Bootnodes []*enode.Node // list of bootstrap nodes Unhandled chan<- ReadPacket // unhandled packets are sent on this channel Log log.Logger // if set, log messages go here ValidSchemes enr.IdentityScheme // allowed identity schemes Clock mclock.Clock }
Config holds settings for the discovery listener.
type ReadPacket ¶
ReadPacket is a packet that couldn't be handled. Those packets are sent to the unhandled channel if configured.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is the 'node table', a Kademlia-like index of neighbor nodes. The table keeps itself up-to-date by verifying the liveness of neighbors and requesting their node records when announcements of a new record version are received.
type UDPConn ¶
type UDPConn interface { ReadFromUDP(b []byte) (n int, addr *net.UDPAddr, err error) WriteToUDP(b []byte, addr *net.UDPAddr) (n int, err error) Close() error LocalAddr() net.Addr }
UDPConn is a network connection on which discovery can operate.
type UDPv5 ¶
type UDPv5 struct {
// contains filtered or unexported fields
}
UDPv5 is the implementation of protocol version 5.
func (*UDPv5) AddRecentNode ¶
func (*UDPv5) Lookup ¶
Lookup performs a recursive lookup for the given target. It returns the closest nodes to target.
func (*UDPv5) RandomNodes ¶
func (*UDPv5) RequestENR ¶
requestENR requests n's record.