Documentation ¶
Index ¶
- type Table
- func (t *Table) CacheSize() int
- func (t *Table) Close() error
- func (t *Table) ConnectionFailed(node *pb.Node) error
- func (t *Table) ConnectionSuccess(node *pb.Node) error
- func (t *Table) FindNear(id storj.NodeID, limit int, restrictions ...pb.Restriction) ([]*pb.Node, error)
- func (t *Table) GetBucketIds() (storage.Keys, error)
- func (t *Table) GetBucketTimestamp(id []byte) (time.Time, error)
- func (t *Table) GetNodes(id storj.NodeID) (nodes []*pb.Node, ok bool)
- func (t *Table) Graph(w io.Writer) error
- func (t *Table) K() int
- func (t *Table) Local() pb.Node
- func (t *Table) MaxBucketDepth() (int, error)
- func (t *Table) Self() storj.NodeID
- func (t *Table) SetBucketTimestamp(id []byte, now time.Time) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a routing table that tries to be as correct as possible at the expense of performance.
func New ¶
New creates a new Table. self is the owning node's node id, bucketSize is the kademlia k value, cacheSize is the size of each bucket's replacement cache, and allowedFailures is the number of failures on a given node before the node is removed from the table.
func (*Table) ConnectionFailed ¶
ConnectionFailed should be called whenever a node can't be contacted. If a node fails more than allowedFailures times, it will be removed from the routing table. The failure count is reset every successful connection.
func (*Table) ConnectionSuccess ¶
ConnectionSuccess should be called whenever a node is successfully connected to. It will add or update the node's entry in the routing table.
func (*Table) FindNear ¶
func (t *Table) FindNear(id storj.NodeID, limit int, restrictions ...pb.Restriction) ([]*pb.Node, error)
FindNear will return up to limit nodes in the routing table ordered by kademlia xor distance from the given id.
func (*Table) GetBucketIds ¶
GetBucketIds returns a storage.Keys type of bucket ID's in the Kademlia instance
func (*Table) GetBucketTimestamp ¶
GetBucketTimestamp retrieves time of the last node lookup for a bucket
func (*Table) MaxBucketDepth ¶
MaxBucketDepth returns the largest depth of the routing table tree. This is useful for determining which buckets should be refreshed.