simplert

package
v0.0.0-...-aed94cd Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: Apache-2.0, MIT Imports: 5 Imported by: 0

README

Simple Routing Table

Author: Guillaume Michel

SimpleRT is a very simple Kademlia Routing Table implementation. It is not meant to be used in production.

Disclaimers

  • NearestPeers isn't optimized at all, but it will work.
  • SimpleRT never refreshes its peers. Hence it will eventually contain a lot of unreachable peers if used outside of a simulation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimpleRT

type SimpleRT[K kad.Key[K], N kad.NodeID[K]] struct {
	// contains filtered or unexported fields
}

func New

func New[K kad.Key[K], N kad.NodeID[K]](self N, bucketSize int) *SimpleRT[K, N]

func (*SimpleRT[K, N]) AddNode

func (rt *SimpleRT[K, N]) AddNode(id N) bool

func (*SimpleRT[K, N]) BucketIdForKey

func (rt *SimpleRT[K, N]) BucketIdForKey(kadId K) (int, error)

func (*SimpleRT[K, N]) BucketSize

func (rt *SimpleRT[K, N]) BucketSize() int

func (*SimpleRT[K, N]) Cpl

func (rt *SimpleRT[K, N]) Cpl(kk K) int

Cpl returns the longest common prefix length the supplied key shares with the table's key.

func (*SimpleRT[K, N]) CplSize

func (rt *SimpleRT[K, N]) CplSize(cpl int) int

CplSize returns the number of nodes in the table whose longest common prefix with the table's key is of length cpl.

func (*SimpleRT[K, N]) GetNode

func (rt *SimpleRT[K, N]) GetNode(kadId K) (N, bool)

func (*SimpleRT[K, N]) KeySize

func (rt *SimpleRT[K, N]) KeySize() int

func (*SimpleRT[K, N]) NearestNodes

func (rt *SimpleRT[K, N]) NearestNodes(kadId K, n int) []N

TODO: not exactly working as expected returns min(n, bucketSize) peers from the bucket matching the given key

func (*SimpleRT[K, N]) RemoveKey

func (rt *SimpleRT[K, N]) RemoveKey(kadId K) bool

func (*SimpleRT[K, N]) Self

func (rt *SimpleRT[K, N]) Self() K

func (*SimpleRT[K, N]) SizeOfBucket

func (rt *SimpleRT[K, N]) SizeOfBucket(bucketId int) int

Jump to

Keyboard shortcuts

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