discover

package
v0.0.0-...-10ab3e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

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

func ListenUDP

func ListenUDP(c conn, ln *enode.LocalNode, cfg Config) (*Table, *Udp, error)

ListenUDP returns a new table that listens for UDP packets on laddr.

func SetResponseTimeout

func SetResponseTimeout(t time.Duration)

Types

type Config

type Config struct {
	// These settings are required and configure the UDP listener:
	PrivateKey *ecdsa.PrivateKey

	// 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
}

Config holds Table-related settings.

type ReadPacket

type ReadPacket struct {
	Data []byte
	Addr *net.UDPAddr
}

ReadPacket is sent to the unhandled channel when it could not be processed

type Table

type Table struct {
	// contains filtered or unexported fields
}

func (*Table) Close

func (tab *Table) Close()

Close terminates the network listener and flushes the node database.

func (*Table) LookupRandom

func (tab *Table) LookupRandom() []*enode.Node

LookupRandom finds random nodes in the network.

func (*Table) ReadRandomNodes

func (tab *Table) ReadRandomNodes(buf []*enode.Node) (n int)

ReadRandomNodes fills the given slice with random nodes from the table. The results are guaranteed to be unique for a single invocation, no node will appear twice.

func (*Table) Resolve

func (tab *Table) Resolve(n *enode.Node) *enode.Node

Resolve searches for a specific node with the given ID. It returns nil if the node could not be found.

type Udp

type Udp struct {
	// contains filtered or unexported fields
}

Udp implements the discovery v4 UDP wire protocol.

func (*Udp) Findnode

func (t *Udp) Findnode(toid enode.ID, toaddr *net.UDPAddr, key *ecdsa.PublicKey) ([]*node, error)

func (*Udp) SendPing

func (t *Udp) SendPing(toid enode.ID, toaddr *net.UDPAddr, callback func()) <-chan error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL