btree

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 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
}

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 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 PrometheusCollector added in v0.2.0

type PrometheusCollector struct {
	Btree          Btree
	CountGauge     prometheus.Gauge
	AddedCounter   prometheus.Counter
	DroppedCounter prometheus.Counter
}

func (PrometheusCollector) Closest added in v0.2.0

func (p PrometheusCollector) Closest(id NodeID, count int) []NodeID

func (PrometheusCollector) Count added in v0.2.0

func (p PrometheusCollector) Count() int

func (PrometheusCollector) Drop added in v0.2.0

func (p PrometheusCollector) Drop(id NodeID) bool

func (PrometheusCollector) Has added in v0.2.0

func (p PrometheusCollector) Has(id NodeID) bool

func (PrometheusCollector) N added in v0.2.0

func (p PrometheusCollector) N() int

func (PrometheusCollector) Put added in v0.2.0

type PutResult

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

func (PutResult) String

func (r PutResult) String() string

Jump to

Keyboard shortcuts

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