Documentation ¶
Overview ¶
Package discv5 implements the RLPx v5 Topic Discovery Protocol.
The Topic 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
- type Network
- func (net *Network) Close()
- func (net *Network) Lookup(targetID NodeID) []*Node
- func (net *Network) ReadRandomNodes(buf []*Node) (n int)
- func (net *Network) RegisterTopic(topic Topic, stop <-chan struct{})
- func (net *Network) Resolve(targetID NodeID) *Node
- func (net *Network) SearchTopic(topic Topic, setPeriod <-chan time.Duration, found chan<- *Node, ...)
- func (net *Network) Self() *Node
- func (net *Network) SetFallbackNodes(nodes []*Node) error
- type Node
- type NodeID
- type Table
- type Topic
Examples ¶
Constants ¶
View Source
const Version = 4
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
func ListenUDP ¶
func ListenUDP(priv *ecdsa.PrivateKey, conn conn, realaddr *net.UDPAddr, nodeDBPath string, netrestrict *netutil.Netlist) (*Network, error)
ListenUDP returns a new table that listens for UDP packets on laddr.
func (*Network) ReadRandomNodes ¶
func (*Network) RegisterTopic ¶
func (*Network) SearchTopic ¶
func (*Network) SetFallbackNodes ¶
type Node ¶
func MustParseNode ¶
func NewNode ¶
Example ¶
id := MustHexID("1dd9d65c4552b5eb43d5ad55a2ee3f56c6cbc1c64a5c8d659f51fcd51bace24351232b8d7821617d2b29b54b81cdefb9b3e9c37d7fd5f63270bcc9e1a6f6a439") n1 := NewNode(id, net.ParseIP("2001:db8:3c4d:15::abcd:ef12"), 52150, 30303) fmt.Println("n1:", n1) fmt.Println("n1.Incomplete() ->", n1.Incomplete()) n2 := NewNode(id, nil, 0, 0) fmt.Println("n2:", n2) fmt.Println("n2.Incomplete() ->", n2.Incomplete())
Output:
func (*Node) Incomplete ¶
func (*Node) MarshalText ¶
func (*Node) UnmarshalText ¶
Click to show internal directories.
Click to hide internal directories.