Documentation ¶
Index ¶
- Constants
- Variables
- type Bucket
- type EvictedElement
- type PeerBucketInfo
- type PeerBucketInfoList
- type PeerStatus
- type RejectMap
- type RoutingTable
- func (rt *RoutingTable) AccessPeer(id address.PeerId) error
- func (rt *RoutingTable) Add(info PeerBucketInfo) error
- func (rt *RoutingTable) GetAllPeers() ([]PeerBucketInfo, error)
- func (rt *RoutingTable) GetClosestTo(nodeTgt []byte) ([]PeerBucketInfo, error)
- func (rt *RoutingTable) Remove(id address.PeerId) error
- func (rt *RoutingTable) SortByDistanceFromTarget(target []byte, list []PeerBucketInfo) []PeerBucketInfo
Constants ¶
const (
MaxRetries int = 3
)
const RejectSecs = 100
const (
RetryPoolLen = 10 // the length of the retry pool
)
Variables ¶
var ( ErrNotFound = errors.New("bucket: id not found") ErrManipulation = errors.New("bucket: error while manipulation or casting") )
var (
ErrCplCompute = errors.New("error while cpl compute")
)
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct { Cpl int // The cpl of the bucket // contains filtered or unexported fields }
Bucket Individual bucket of the RoutingTable.
func (*Bucket) AddOrUpdate ¶
func (b *Bucket) AddOrUpdate(info PeerBucketInfo, abstainLock bool) error
AddOrUpdate Add or Update the existing PeerBucketInfo If it is greater than bucketSize then it is added to a retry list which will be invoked before next add The live-ness check worker should ping and delete the Dead nodes. there by clearing some space in the k bucket
func (*Bucket) GetAll ¶
func (b *Bucket) GetAll() ([]PeerBucketInfo, error)
GetAll gets all the information from the bucket.
type EvictedElement ¶ added in v0.0.4
type PeerBucketInfo ¶
type PeerBucketInfo struct { PeerAddr address.PeerAddressInfo // The Peer Address info - for comm LastAliveAt int64 // Epoch of the last PingResponse arrival. NumRetries int64 // Number of retries when the node is in suspicious/ suspected state. }
PeerBucketInfo contains all the necessary information of the peer in k-bucket.
func WrapPeerAddrInfo ¶
func WrapPeerAddrInfo(info address.PeerAddressInfo) PeerBucketInfo
WrapPeerAddrInfo Wraps PeerBucketInfo over PeerAddressInfo Helper Utility
func (*PeerBucketInfo) SyncWith ¶ added in v0.0.4
func (pbi *PeerBucketInfo) SyncWith(pbl PeerBucketInfo) PeerBucketInfo
type PeerBucketInfoList ¶
type PeerBucketInfoList struct {
// contains filtered or unexported fields
}
PeerBucketInfoList Wrapper for slice of PeerBucketInfo Implements the sort interface for sort functionality
func (*PeerBucketInfoList) Len ¶
func (pbl *PeerBucketInfoList) Len() int
func (*PeerBucketInfoList) Less ¶
func (pbl *PeerBucketInfoList) Less(i, j int) bool
func (*PeerBucketInfoList) Swap ¶
func (pbl *PeerBucketInfoList) Swap(i, j int)
type PeerStatus ¶
type PeerStatus int
type RejectMap ¶ added in v0.0.4
type RejectMap struct {
// contains filtered or unexported fields
}
func NewRejectMap ¶ added in v0.0.4
func NewRejectMap() *RejectMap
type RoutingTable ¶
type RoutingTable struct {
// contains filtered or unexported fields
}
RoutingTable RoutingTable - The k-bucket ds. Currently the RoutingTable is in memory TODO: Add Persistent Routing table flavour as well
func NewRoutingTable ¶
func NewRoutingTable(homeNodeId address.PeerId, k int) *RoutingTable
NewRoutingTable returns a new InMemory Routing table.
func (*RoutingTable) AccessPeer ¶
func (rt *RoutingTable) AccessPeer(id address.PeerId) error
AccessPeer - should be called when a particular peer is "accessed" To maintain the LRU style listing. Currently Even if the List is maintained in LRU fashion, Ping/ eviction is decoupled from the bucket's responsibilities. If So then this Access API serves no use. TODO: Refactor this, see existing impls, and check if it is the bucket's job to evict? Alternate would be directly exposing the bucket for a cpl and feed it to the worker Like a "LookUp with Follow Up design"
func (*RoutingTable) Add ¶
func (rt *RoutingTable) Add(info PeerBucketInfo) error
Add adds a Peer Bucket info to the RoutingTable
func (*RoutingTable) GetAllPeers ¶
func (rt *RoutingTable) GetAllPeers() ([]PeerBucketInfo, error)
GetAllPeers gets all the peers from the peer store. Ordered by the distance from home node.
func (*RoutingTable) GetClosestTo ¶
func (rt *RoutingTable) GetClosestTo(nodeTgt []byte) ([]PeerBucketInfo, error)
GetClosestTo gets the peers from the peer store and orders by the supplied nodeTgt.
func (*RoutingTable) Remove ¶
func (rt *RoutingTable) Remove(id address.PeerId) error
Remove Removes the entry with the specified Id This is usually done when the node goes offline and the live-ness checker finds about it.
func (*RoutingTable) SortByDistanceFromTarget ¶
func (rt *RoutingTable) SortByDistanceFromTarget(target []byte, list []PeerBucketInfo) []PeerBucketInfo
SortByDistanceFromTarget Utility method to sort the list by the "Distance from target" metric.