topology

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package topology exposes abstractions needed in topology-aware components.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("no peer found")
	ErrWantSelf      = errors.New("node wants self")
	ErrOversaturated = errors.New("oversaturated")
)

Functions

This section is empty.

Types

type ClosestPeerer

type ClosestPeerer interface {
	// ClosestPeer returns the closest connected peer we have in relation to a
	// given chunk address.
	// This function will ignore peers with addresses provided in skipPeers.
	// Returns topology.ErrWantSelf in case base is the closest to the address.
	ClosestPeer(addr boson.Address, includeSelf bool, f Filter, skipPeers ...boson.Address) (peerAddr boson.Address, err error)
	ClosestPeers(addr boson.Address, limit int, f Filter, skipPeers ...boson.Address) ([]boson.Address, error)
}

type Driver

type Driver interface {
	p2p.Notifier
	PeerAdder
	ClosestPeerer
	EachPeerer
	EachNeighbor
	NeighborhoodDepther
	SubscribePeersChange(notifier subscribe.INotifier)
	SubscribePeerState(notifier subscribe.INotifier)
	io.Closer
	Halter
	Snapshot() *model.KadParams
	SnapshotConnected() (connected int, peers map[string]*model.PeerInfo)
	SnapshotAddr(addr boson.Address) *model.Snapshot
	GetPeersWithLatencyEWMA(list []boson.Address) (now []boson.Address)
	RecordPeerLatency(add boson.Address, t time.Duration)
	DisconnectForce(addr boson.Address, reason string) error
	Outbound(peer p2p.Peer)
	NotifyPeerState(peer p2p.PeerInfo)
	EachKnownPeerer
	ProtectPeer
}

type EachKnownPeerer

type EachKnownPeerer interface {
	// EachKnownPeer iterates from closest bin to farthest
	EachKnownPeer(model.EachPeerFunc) error
	// EachKnownPeerRev iterates from farthest bin to closest
	EachKnownPeerRev(model.EachPeerFunc) error
}

type EachNeighbor

type EachNeighbor interface {
	// EachNeighbor iterates from closest bin to farthest within the neighborhood.
	EachNeighbor(model.EachPeerFunc) error
	// EachNeighborRev iterates from farthest bin to closest within the neighborhood.
	EachNeighborRev(model.EachPeerFunc) error
	// IsWithinDepth checks if an address is the within neighborhood.
	IsWithinDepth(boson.Address) bool
}

type EachPeerer

type EachPeerer interface {
	// EachPeer iterates from closest bin to farthest
	EachPeer(model.EachPeerFunc, Filter) error
	// EachPeerRev iterates from farthest bin to closest
	EachPeerRev(model.EachPeerFunc, Filter) error
}

type Filter

type Filter struct {
	Reachable bool
}

Filter defines the different filters that can be used with the Peer iterators

type Halter

type Halter interface {
	// Halt the topology from initiating new connections
	// while allowing it to still run.
	Halt()
}

type NeighborhoodDepther

type NeighborhoodDepther interface {
	NeighborhoodDepth() uint8
}

type PeerAdder

type PeerAdder interface {
	// AddPeers is called when peers are added to the topology backlog
	AddPeers(addr ...boson.Address)
}

type ProtectPeer

type ProtectPeer interface {
	RefreshProtectPeer(peer []boson.Address)
}

Directories

Path Synopsis
Package kademlia provides an implementation of the topology.Driver interface in a way that a kademlia connectivity is actively maintained by the node.
Package kademlia provides an implementation of the topology.Driver interface in a way that a kademlia connectivity is actively maintained by the node.
internal/metrics
Package metrics provides service for collecting various metrics about peers.
Package metrics provides service for collecting various metrics about peers.
internal/waitnext
Package waitnext Package metrics provides service for collecting various metrics about peers.
Package waitnext Package metrics provides service for collecting various metrics about peers.

Jump to

Keyboard shortcuts

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