testrouting

package
v0.8.7 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

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

func New(self storj.NodeID, bucketSize, cacheSize, allowedFailures int) *Table

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) CacheSize

func (t *Table) CacheSize() int

CacheSize returns the size of replacement cache

func (*Table) Close

func (t *Table) Close() error

Close closes without closing dependencies

func (*Table) ConnectionFailed

func (t *Table) ConnectionFailed(node *pb.Node) error

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

func (t *Table) ConnectionSuccess(node *pb.Node) error

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

func (t *Table) GetBucketIds() (storage.Keys, error)

GetBucketIds returns a storage.Keys type of bucket ID's in the Kademlia instance

func (*Table) GetBucketTimestamp

func (t *Table) GetBucketTimestamp(id []byte) (time.Time, error)

GetBucketTimestamp retrieves time of the last node lookup for a bucket

func (*Table) GetNodes

func (t *Table) GetNodes(id storj.NodeID) (nodes []*pb.Node, ok bool)

GetNodes retrieves nodes within the same kbucket as the given node id

func (*Table) Graph

func (t *Table) Graph(w io.Writer) error

Graph writes a DOT format visual graph description of the routing table to w

func (*Table) K

func (t *Table) K() int

K returns the Table's routing depth, or Kademlia k value

func (*Table) Local

func (t *Table) Local() pb.Node

Local returns the local nodes ID

func (*Table) MaxBucketDepth

func (t *Table) MaxBucketDepth() (int, error)

MaxBucketDepth returns the largest depth of the routing table tree. This is useful for determining which buckets should be refreshed.

func (*Table) Self

func (t *Table) Self() storj.NodeID

Self returns the node's configured node id.

func (*Table) SetBucketTimestamp

func (t *Table) SetBucketTimestamp(id []byte, now time.Time) error

SetBucketTimestamp records the time of the last node lookup for a bucket

Jump to

Keyboard shortcuts

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