key

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2025 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const BitPanicMsg = "bit index out of range"

Variables

View Source
var ErrInvalidDataLength = errors.New("invalid data length")

ErrInvalidDataLength is the error returned when attempting to construct a key from binary data of the wrong length.

Functions

func BitString

func BitString[K kad.Key[K]](k K) string

BitString returns a string containing the binary representation of a key.

func CommonPrefixLength added in v0.2.0

func CommonPrefixLength[K0 kad.Key[K0], K1 kad.Key[K1]](a K0, b K1) int

CommonPrefixLength returns the length of the common prefix of two keys. Note that keys can be of different types, and different lengths.

func Equal

func Equal[K kad.Key[K]](a, b K) bool

Equal reports whether two keys have equal numeric values.

func HexString

func HexString[K kad.Key[K]](k K) string

HexString returns a string containing the hexadecimal representation of a key.

func IsSorted

func IsSorted[K kad.Key[K]](ks []K) bool

IsSorted reports whether a list of keys is sorted in ascending numerical order.

Types

type KeyList

type KeyList[K kad.Key[K]] []K

KeyList is a list of Kademlia keys. It implements sort.Interface.

func (KeyList[K]) Len

func (ks KeyList[K]) Len() int

func (KeyList[K]) Less

func (ks KeyList[K]) Less(i, j int) bool

func (KeyList[K]) Swap

func (ks KeyList[K]) Swap(i, j int)

Directories

Path Synopsis
Package bit256 provides a 256-bit Kademlia key implementation.
Package bit256 provides a 256-bit Kademlia key implementation.

Jump to

Keyboard shortcuts

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