discovery

package
v0.0.0-...-7de8d3f Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DistCmp

func DistCmp(target, a, b ID) int

DistCmp compares the distances a->target and b->target. Returns -1 if a is closer to target, 1 if b is closer to target and 0 if they are equal.

func LogDist

func LogDist(a, b ID) int

LogDist returns the logarithmic distance between a and b, log2(a ^ b).

func NewUDP

func NewUDP(node INode, metricCollector IMetricCollector) (*Table, *UDP)

Types

type DB

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

func (*DB) FindFails

func (db *DB) FindFails(n INode) int

func (*DB) LastPingReceived

func (db *DB) LastPingReceived(n INode) float64

func (*DB) LastPongReceived

func (db *DB) LastPongReceived(n INode) float64

func (*DB) QuerySeeds

func (db *DB) QuerySeeds(n int) []INode

QuerySeeds retrieves random nodes to be used as potential seed nodes for bootstrapping.

func (*DB) UpdateFindFails

func (db *DB) UpdateFindFails(n INode, fails int)

func (*DB) UpdateLastPingReceived

func (db *DB) UpdateLastPingReceived(n INode, time float64)

func (*DB) UpdateLastPongReceived

func (db *DB) UpdateLastPongReceived(n INode, time float64)

type Table

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

func (*Table) Close

func (tab *Table) Close()

func (*Table) Closest

func (tab *Table) Closest(pubKey encPubkey) *nodesByDistance

func (*Table) LookupRandom

func (tab *Table) LookupRandom() []INode

LookupRandom finds random nodes in the network.

func (*Table) ReadRandomNodes

func (tab *Table) ReadRandomNodes(buf []INode) (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 INode) INode

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

func (*Table) SetOnline

func (tab *Table) SetOnline(online bool)

type UDP

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

UDP implements the discovery v4 UDP wire protocol.

Jump to

Keyboard shortcuts

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