dht

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const BucketSize = 16

BucketSize defines the NodeID, Key, and routing table data structures.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	*list.List
	// contains filtered or unexported fields
}

Bucket holds a list of contacts of this node.

func NewBucket

func NewBucket() *Bucket

NewBucket is a Factory method of Bucket, contains an empty list.

type RoutingTable

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

RoutingTable contains one bucket list for lookups.

func CreateRoutingTable

func CreateRoutingTable(id peer.ID) *RoutingTable

CreateRoutingTable is a Factory method of RoutingTable containing empty buckets.

func (*RoutingTable) Bucket

func (t *RoutingTable) Bucket(id int) *Bucket

Bucket returns a specific Bucket by ID.

func (*RoutingTable) FindClosestPeers

func (t *RoutingTable) FindClosestPeers(target peer.ID, count int) (peers []peer.ID)

FindClosestPeers returns a list of k(count) peers with smallest XOR distance.

func (*RoutingTable) GetPeerAddresses

func (t *RoutingTable) GetPeerAddresses() (peers []string)

GetPeerAddresses returns a unique list of all peer addresses within the routing network.

func (*RoutingTable) GetPeers

func (t *RoutingTable) GetPeers() (peers []peer.ID)

GetPeers returns a randomly-ordered, unique list of all peers within the routing network (excluding itself).

func (*RoutingTable) PeerExists

func (t *RoutingTable) PeerExists(target peer.ID) bool

PeerExists checks if a peer exists in the routing table with O(bucket_size) time complexity.

func (*RoutingTable) RemovePeer

func (t *RoutingTable) RemovePeer(target peer.ID) bool

RemovePeer removes a peer from the routing table with O(bucket_size) time complexity.

func (*RoutingTable) Self

func (t *RoutingTable) Self() peer.ID

Self returns the ID of the node hosting the current routing table instance.

func (*RoutingTable) Update

func (t *RoutingTable) Update(target peer.ID)

Update moves a peer to the front of a bucket in the routing table.

Jump to

Keyboard shortcuts

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