Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrKBucketNotExist = errors.New("kbucket: no such node") ErrKBucketFull = errors.New("kbucket: bucket full") ErrKBucketEmpty = errors.New("kbucket: bucket empty") )
Standard errors a KBucket can give.
View Source
var ( ErrRTableFull = errors.New("rtable: table full") ErrRTableClosed = errors.New("rtable: closed") )
Standard errors a RTable can give.
Functions ¶
This section is empty.
Types ¶
type KBucket ¶
type KBucket interface {
// Load node by ID. If no node exists with that ID in the bucket, return
// ErrKBucketNotFound.
Load(id []byte) (*core.NodeTriple, error)
// Store or update node. If the bucket is full, return ErrKBucketFull.
Store(n *core.NodeTriple) error
// Load oldest node in bucket.
Oldest() (*core.NodeTriple, error)
// Remove node by ID.
Remove(id []byte) error
// Append bucket contents to slice s, in order of most recent first,
// until s is at most length n.
Append(s []*core.NodeTriple, n int) ([]*core.NodeTriple, error)
// Close the KBucket.
io.Closer
}
KBucket stores nodes in an LRU cache. KBucket is not safe for concurrent use.
type RTable ¶
type RTable interface {
// Store a node. If the RTable is full, return ErrRTableFull.
Store(n *core.NodeTriple) error
// Oldest node in the id's corresponding bucket.
Oldest(id []byte) (*core.NodeTriple, error)
// Replace replace the oldest node with n.
ReplaceOldest(n *core.NodeTriple) error
// Closest finds at most k closest, unequal nodes to id.
Closest(id []byte, k int) ([]*core.NodeTriple, error)
// Close the RTable. All future operations return ErrRtableClosed.
io.Closer
}
RTable stores nodes. RTable is safe for concurrent use.
Click to show internal directories.
Click to hide internal directories.