Documentation ¶
Index ¶
Constants ¶
const Version = 4
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NodeId ¶
type NodeId [nodeIdLen]byte
func Hex2NodeId ¶
func MustHex2NodeId ¶
func PubKey2NodeId ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
func ListenUDP ¶
func ListenUDP(priv *ecdsa.PrivateKey, laddr string, nodeDBPath string, mapper nat.Mapper) (*Table, error)
ListenUDP returns a new table that listens for UDP packets on laddr.
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.
func (*Table) Close ¶
func (tab *Table) Close()
Close terminates the network listener and flushes the node database.
func (*Table) Lookup ¶
Lookup performs a network search for nodes close to the given target. It approaches the target by querying nodes that are closer to it on each iteration. The given target does not need to be an actual node identifier.
func (*Table) ReadRandomNodes ¶
ReadRandomNodes fills the given slice with random nodes from the table. It will not write the same node more than once. The nodes in the slice are copies and can be modified by the caller.