state

package
v0.0.0-...-606166f Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package state contains structures related to a node's state as documented in the pastry paper.

This includes, the LeafSet, a more generalized Set, and the RoutingTable.

Index

Constants

This section is empty.

Variables

View Source
var Length int = 10

Functions

This section is empty.

Types

type LeafSet

type LeafSet struct {
	// contains filtered or unexported fields
}

LeafSet contains the sets of numerically closer and farther from the node.

func NewLeafSet

func NewLeafSet(key peer.ID) LeafSet

func (LeafSet) Closest

func (l LeafSet) Closest(id peer.ID) *peer.AddrInfo

Closest returns the closest PeerInfo.

func (*LeafSet) Insert

func (l *LeafSet) Insert(peer *peer.AddrInfo)

Insert inserts a peer in the LeafSet.

func (LeafSet) IsInRange

func (l LeafSet) IsInRange(id peer.ID) bool

IsInRange returns whether an id is between the Min and Max IDs in the LeafSet.

func (LeafSet) Max

func (l LeafSet) Max() peer.ID

Max returns the farthest key to the larger side.

func (LeafSet) Min

func (l LeafSet) Min() peer.ID

Min returns the farthest key to the smaller side.

func (*LeafSet) Remove

func (l *LeafSet) Remove(id peer.ID) bool

Remove removes a peer from the LeafSet.

type RoutingTable

type RoutingTable [][]*peer.AddrInfo

func (RoutingTable) Route

func (r RoutingTable) Route(self, target peer.ID) *peer.AddrInfo

type Set

type Set []*peer.AddrInfo

Set represents a Set of nodes

func (Set) Closest

func (s Set) Closest(id peer.ID) *peer.AddrInfo

Closest returns the closest peer to a specific ID.

func (Set) IndexOf

func (s Set) IndexOf(id peer.ID) int

IndexOf returns the index of the given peer id.

func (Set) Insert

func (s Set) Insert(peer *peer.AddrInfo) Set

Insert adds a peer to the Set.

func (Set) Remove

func (s Set) Remove(id peer.ID) (Set, bool)

Remove removes a peer with a given id.

Jump to

Keyboard shortcuts

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