structs

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// a small number representing the degree of parallelism in network calls
	Alpha = 3

	// the size in bits of the keys used to identify nodes and store and
	// retrieve data; in basic Kademlia this is 160, the length of a SHA1
	B = 160

	// the maximum number of contacts stored in a bucket
	K = 5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message added in v0.5.8

type Message struct {
	IP     net.IP
	Buffer *[]byte
}

type Node

type Node struct {
	ID   []byte `json:"id,omitempty"`
	IP   string `json:"ip,omitempty"`
	Port int    `json:"port,omitempty"`
}

func (*Node) Equal

func (b *Node) Equal(other Node) bool

type RoutingTable

type RoutingTable struct {
	NodeInfo Node
	KBuckets [B][]Node
	// contains filtered or unexported fields
}

func NewRoutingTable

func NewRoutingTable(b Node) *RoutingTable

func (*RoutingTable) AddNode

func (rt *RoutingTable) AddNode(b Node) error

Función que se encarga de añadir un nodo a la tabla de rutas con las restricciones pertinentes del protocolo

func (*RoutingTable) GetClosestContacts

func (rt *RoutingTable) GetClosestContacts(num int, target []byte, ignoredNodes []*Node) *ShortList

type ShortList

type ShortList struct {
	// Nodes are a list of nodes to be compared
	Nodes *[]Node

	// Comparator is the ID to compare to
	Comparator []byte
}

nodeList is used in order to sort a list of arbitrary nodes against a comparator. These nodes are sorted by xor distance

func (*ShortList) Append

func (n *ShortList) Append(nodes []*Node)

func (*ShortList) Len

func (n *ShortList) Len() int

func (*ShortList) Less

func (n *ShortList) Less(i, j int) bool

func (*ShortList) RemoveNode

func (n *ShortList) RemoveNode(node *Node)

func (*ShortList) Swap

func (n *ShortList) Swap(i, j int)

type Storage

type Storage struct {
	KV map[string]*[]byte
}

func NewStorage

func NewStorage() *Storage

func (*Storage) Create

func (s *Storage) Create(key []byte, data *[]byte) error

func (*Storage) Delete

func (s *Storage) Delete(key []byte) error

func (*Storage) GetKeys added in v0.5.4

func (s *Storage) GetKeys() [][]byte

func (*Storage) Read

func (s *Storage) Read(key []byte, start int64, end int64) (*[]byte, error)

Jump to

Keyboard shortcuts

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