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 ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct { ID NodeID IP net.IP DiscPort int // UDP listening port for discovery protocol TCPPort int // TCP listening port for RLPx // contains filtered or unexported fields }
Node represents a host on the network.
func MustParseNode ¶
MustParseNode parses a node URL. It panics if the URL is not valid.
func ParseNode ¶
ParseNode parses a node URL.
A node URL has scheme "enode".
The hexadecimal node ID is encoded in the username portion of the URL, separated from the host by an @ sign. The hostname can only be given as an IP address, DNS domain names are not allowed. The port in the host name section is the TCP listening port. If the TCP and UDP (discovery) ports differ, the UDP port is specified as query parameter "discport".
In the following example, the node URL describes a node with IP address 10.3.58.6, TCP listening port 30303 and UDP discovery port 30301.
enode://<hex node id>@10.3.58.6:30303?discport=30301
type NodeID ¶
type NodeID [nodeIDBits / 8]byte
NodeID is a unique identifier for each node. The node identifier is a marshaled elliptic curve public key.
func MustHexID ¶
MustHexID converts a hex string to a NodeID. It panics if the string is not a valid NodeID.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func (*Table) Bootstrap ¶
Bootstrap sets the bootstrap nodes. These nodes are used to connect to the network if the table is empty. Bootstrap will also attempt to fill the table by performing random lookup operations on the network.