topology

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: BSD-3-Clause Imports: 5 Imported by: 7

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, skipPeers ...boson.Address) (peerAddr boson.Address, err error)
	ClosestPeers(addr boson.Address, limit int, skipPeers ...boson.Address) ([]boson.Address, error)
}

type Driver

type Driver interface {
	p2p.Notifier
	PeerAdder
	ClosestPeerer
	EachPeerer
	EachNeighbor
	NeighborhoodDepther
	SubscribePeersChange() (c <-chan struct{}, unsubscribe func())
	io.Closer
	Halter
	Snapshot() *model.KadParams
	DisconnectForce(addr boson.Address, reason string) error
	Outbound(peer p2p.Peer)
	EachKnownPeerer
}

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) error
	// EachPeerRev iterates from farthest bin to closest
	EachPeerRev(model.EachPeerFunc) error
}

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)
}

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