btree

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bit

type Bit bool
const (
	Bit0 Bit = false
	Bit1 Bit = true
)

type Bits

type Bits []Bit

func (Bits) Cmp

func (b Bits) Cmp(other Bits) int

func (Bits) LeadingZeros

func (b Bits) LeadingZeros() int

func (Bits) String

func (b Bits) String() string

type Btree

type Btree interface {
	N() int
	Put(NodeID) PutResult
	Has(NodeID) bool
	Drop(NodeID) bool
	Closest(NodeID, int) []NodeID
	Count() int
	EmptiestPrefixLengths() []int
	Stats() Stats
	// contains filtered or unexported methods
}

Btree is the binary tree implementation used by the Kademlia routing table. The Kademlia literature refers to "buckets" that can be "split" according to certain rules when they are full. This implementation does not use buckets exactly as described in the literature, but rather a simpler binary tree, however the end result is largely equivalent.

func New

func New(origin NodeID, k int, splittingEnabled bool) Btree

type BucketStats

type BucketStats struct {
	N     int
	Count int
}

type NodeID

type NodeID []byte

func MustParseBinaryNodeID

func MustParseBinaryNodeID(str string) NodeID

func ParseBinaryNodeID

func ParseBinaryNodeID(str string) (NodeID, error)

func (NodeID) BinaryString

func (id NodeID) BinaryString() string

func (NodeID) Bits

func (id NodeID) Bits() Bits

func (NodeID) Equals

func (id NodeID) Equals(other NodeID) bool

func (NodeID) GetBit

func (id NodeID) GetBit(n int) Bit

func (NodeID) MustXor

func (id NodeID) MustXor(other NodeID) NodeID

func (NodeID) String

func (id NodeID) String() string

func (NodeID) Xor

func (id NodeID) Xor(other NodeID) (NodeID, error)

type PutResult

type PutResult int
const (
	PutRejected PutResult = iota
	PutAccepted
	PutAlreadyExists
)

func (PutResult) String

func (r PutResult) String() string

type Stats

type Stats struct {
	Buckets []BucketStats
}

Jump to

Keyboard shortcuts

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