discover

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: GPL-3.0 Imports: 22 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

This section is empty.

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
	Log         log.Logger        // if set, log messages go here
}

Config holds Table-related settings.

type ReadPacket

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

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
}

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 UDPConn added in v1.9.0

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
}

type UDPv4 added in v1.9.0

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

UDPv4 implements the v4 wire protocol.

func ListenUDP

func ListenUDP(c UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv4, error)

ListenUDP starts listening for discovery packets on the given UDP socket.

func ListenV4 added in v1.9.0

func ListenV4(c UDPConn, ln *enode.LocalNode, cfg Config) (*UDPv4, error)

func (*UDPv4) Close added in v1.9.0

func (t *UDPv4) Close()

Close shuts down the socket and aborts any running queries.

func (*UDPv4) LookupPubkey added in v1.9.0

func (t *UDPv4) LookupPubkey(key *ecdsa.PublicKey) []*enode.Node

func (*UDPv4) LookupRandom added in v1.9.0

func (t *UDPv4) LookupRandom() []*enode.Node

LookupRandom finds random nodes in the network.

func (*UDPv4) ReadRandomNodes added in v1.9.0

func (t *UDPv4) ReadRandomNodes(buf []*enode.Node) int

ReadRandomNodes reads random nodes from the local table.

func (*UDPv4) Resolve added in v1.9.0

func (t *UDPv4) 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.

func (*UDPv4) Self added in v1.9.0

func (t *UDPv4) Self() *enode.Node

Self returns the local node.

Jump to

Keyboard shortcuts

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