Documentation ¶
Index ¶
- Constants
- type Bucket
- type RoutingTable
- func (t *RoutingTable) Bucket(id int) *Bucket
- func (t *RoutingTable) FindClosestPeers(target peer.ID, count int) (peers []peer.ID)
- func (t *RoutingTable) GetPeerAddresses() (peers []string)
- func (t *RoutingTable) GetPeers() (peers []peer.ID)
- func (t *RoutingTable) PeerExists(target peer.ID) bool
- func (t *RoutingTable) RemovePeer(target peer.ID) bool
- func (t *RoutingTable) Self() peer.ID
- func (t *RoutingTable) Update(target peer.ID)
Constants ¶
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 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 ¶
FindClosestPeers returns a list of k(count) peers with smallest XorID 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.