kademlia

package
v0.1.0-daot.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package kademlia provides Kademlia routing-related facilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BucketAtDepth

func BucketAtDepth(node key.Key, table *trie.Trie, depth int) *trie.Trie

BucketAtDepth returns the bucket in the routing table at a given depth. A bucket at depth D holds contacts that share a prefix of exactly D bits with node.

func ClosestN

func ClosestN(node key.Key, table *trie.Trie, count int) []key.Key

ClosestN will return the count closest keys to the given key.

Types

type BucketHealthReport

type BucketHealthReport struct {
	// Depth is the bucket depth, starting from zero.
	Depth int
	// MaxKnownContacts is the number of all known network nodes,
	// which are eligible to be in this bucket.
	MaxKnownContacts int
	// ActualKnownContacts is the number of known network nodes,
	// that are actually in the node's routing table.
	ActualKnownContacts int
	// ActualUnknownContacts is the number of contacts in the node's routing table,
	// that are not known to be in the network currently.
	ActualUnknownContacts int
}

BucketHealth describes the discrepancy between a node's routing bucket and the theoretical ideal, given knowledge of all nodes present in the network (aka the "known" nodes).

func BucketHealth

func BucketHealth(node key.Key, nodeTable, knownNodes *trie.Trie) []*BucketHealthReport

BucketHealth computes the health report for each bucket in a node's routing table, given the node's routing table and a list of all known nodes in the network currently.

func (*BucketHealthReport) String

func (bh *BucketHealthReport) String() string

type Table

type Table struct {
	Node     key.Key
	Contacts []key.Key
}

type TableHealthReport

type TableHealthReport struct {
	// IdealDepth is the depth that the node's routing table should have.
	IdealDepth int
	// ActualDepth is the depth that the node's routing table has.
	ActualDepth int
	// Bucket contains the individual health reports for each of the node's routing buckets.
	Bucket []*BucketHealthReport
}

TableHealthReport describes the discrepancy between a node's routing table from the theoretical ideal, given knowledge of all nodes present in the network. TODO: Make printable in a way easy to ingest in Python/matplotlib for viewing in a Jupyter notebook. E.g. one would like to see a histogram of (IdealDepth - ActualDepth) across all tables.

func AllTablesHealth

func AllTablesHealth(tables []*Table) (report []*TableHealthReport)

AllTablesHealth computes health reports for a network of nodes, whose routing contacts are given.

func TableHealth

func TableHealth(node key.Key, nodeContacts []key.Key, knownNodes *trie.Trie) *TableHealthReport

TableHealth computes the health report for a node, given its routing contacts and a list of all known nodes in the network currently.

func TableHealthFromSets

func TableHealthFromSets(node key.Key, nodeContacts []key.Key, knownNodes []key.Key) *TableHealthReport

func (*TableHealthReport) String

func (th *TableHealthReport) String() string

Jump to

Keyboard shortcuts

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