Documentation
¶
Index ¶
- Variables
- func CommonPrefixLen(a, b ID) int
- type Bucket
- type Entry
- type ID
- type RoutingTable
- func (rt *RoutingTable) Find(id string) string
- func (rt *RoutingTable) ListPeers() []string
- func (rt *RoutingTable) NearestPeer(id string) string
- func (rt *RoutingTable) NearestPeers(peer string, count int) []string
- func (rt *RoutingTable) Print()
- func (rt *RoutingTable) Remove(p string)
- func (rt *RoutingTable) Size() int
- func (rt *RoutingTable) Update(p string) (evicted string, err error)
Constants ¶
This section is empty.
Variables ¶
var ErrLookupFailure = errors.New("failed to find any peer in table")
Returned if a routing table query returns no results. This is NOT expected behaviour
var ErrPeerRejectedHighLatency = errors.New("peer rejected; latency too high")
var ErrPeerRejectedNoCapacity = errors.New("peer rejected; insufficient capacity")
Functions ¶
func CommonPrefixLen ¶
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket holds a list of peers.
func (*Bucket) MoveToFront ¶
type ID ¶
type ID []byte
ID for IpfsDHT is in the XORKeySpace
The type dht.ID signifies that its contents have been hashed from either a string or a util.Key. This unifies the keyspace
type RoutingTable ¶
type RoutingTable struct { // kBuckets define all the fingers to other nodes. Buckets []*Bucket // notification functions PeerRemoved func(string) PeerAdded func(string) // contains filtered or unexported fields }
RoutingTable defines the routing table.
func NewRoutingTable ¶
func NewRoutingTable(bucketsize int, peer string, latency time.Duration, hash hash.Hash) *RoutingTable
NewRoutingTable creates a new routing table with a given bucketsize, local ID, and latency tolerance.
func (*RoutingTable) Find ¶
func (rt *RoutingTable) Find(id string) string
Find a specific peer by ID or return nil
func (*RoutingTable) ListPeers ¶
func (rt *RoutingTable) ListPeers() []string
ListPeers takes a RoutingTable and returns a list of all peers from all buckets in the table.
func (*RoutingTable) NearestPeer ¶
func (rt *RoutingTable) NearestPeer(id string) string
NearestPeer returns a single peer that is nearest to the given ID
func (*RoutingTable) NearestPeers ¶
func (rt *RoutingTable) NearestPeers(peer string, count int) []string
NearestPeers returns a list of the 'count' closest peers to the given ID
func (*RoutingTable) Print ¶
func (rt *RoutingTable) Print()
Print prints a descriptive statement about the provided RoutingTable
func (*RoutingTable) Remove ¶
func (rt *RoutingTable) Remove(p string)
Remove deletes a peer from the routing table. This is to be used when we are sure a node has disconnected completely.
func (*RoutingTable) Size ¶
func (rt *RoutingTable) Size() int
Size returns the total number of peers in the routing table