ktable

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDropReasonNotProvided = errors.New("drop reason not provided")

Functions

This section is empty.

Types

type Command

type Command interface {
	// contains filtered or unexported methods
}

type CommandReturn

type CommandReturn[T any] interface {
	Command
	Query[T]
}

type DropAddr

type DropAddr struct {
	Addr   netip.Addr
	Reason error
}

type DropNode

type DropNode struct {
	ID     ID
	Reason error
}

type FilterKnownAddrs

type FilterKnownAddrs struct {
	Addrs []netip.Addr
}

type GetClosestPeers

type GetClosestPeers struct {
	ID ID
}

type GetHashOrClosestNodes

type GetHashOrClosestNodes struct {
	ID ID
}

type GetHashOrClosestNodesResult

type GetHashOrClosestNodesResult struct {
	Hash         Hash
	ClosestNodes []Node
	Found        bool
}

type GetNodesForSampleInfoHashes

type GetNodesForSampleInfoHashes struct {
	N int
}

type GetOldestPeers

type GetOldestPeers struct {
	Cutoff time.Time
	N      int
}

type Hash

type Hash interface {
	Peers() []HashPeer
	Dropped() bool
	// contains filtered or unexported methods
}

type HashOption

type HashOption interface {
	// contains filtered or unexported methods
}

type HashPeer

type HashPeer struct {
	Addr netip.AddrPort
}

type ID

type ID = protocol.ID

type Node

type Node interface {
	Addr() netip.AddrPort
	Time() time.Time
	Dropped() bool
	IsSampleInfoHashesCandidate() bool
	// contains filtered or unexported methods
}

func NewNode

func NewNode(id ID, addr netip.AddrPort) Node

type NodeOption

type NodeOption interface {
	// contains filtered or unexported methods
}

func NodeBep51Support

func NodeBep51Support(supported bool) NodeOption

func NodeResponded

func NodeResponded() NodeOption

func NodeSampleInfoHashesRes

func NodeSampleInfoHashesRes(discoveredNum int, totalNum int, nextSampleTime time.Time) NodeOption

type Params

type Params struct {
	fx.In
	NodeID ID `name:"dht_node_id"`
}

type PutHash

type PutHash struct {
	ID      ID
	Peers   []HashPeer
	Options []HashOption
}

type PutNode

type PutNode struct {
	ID      ID
	Addr    netip.AddrPort
	Options []NodeOption
}

type Query

type Query[T any] interface {
	// contains filtered or unexported methods
}

type Result

type Result struct {
	fx.Out
	Table                Table
	NodesCountGauge      prometheus.Collector `group:"prometheus_collectors"`
	NodesAddedCounter    prometheus.Collector `group:"prometheus_collectors"`
	NodesDroppedCounter  prometheus.Collector `group:"prometheus_collectors"`
	HashesCountGauge     prometheus.Collector `group:"prometheus_collectors"`
	HashesAddedCounter   prometheus.Collector `group:"prometheus_collectors"`
	HashesDroppedCounter prometheus.Collector `group:"prometheus_collectors"`
}

func New

func New(p Params) Result

type SampleHashesAndNodes

type SampleHashesAndNodes struct{}

type SampleHashesAndNodesResult

type SampleHashesAndNodesResult struct {
	Hashes      []Hash
	Nodes       []Node
	TotalHashes int
}

type Table

type Table interface {
	TableOrigin
	TableCommand
	TableQuery
	BatchCommand(commands ...Command)
}

type TableCommand

type TableCommand interface {
	PutNode(id ID, addr netip.AddrPort, options ...NodeOption) btree.PutResult
	DropNode(id ID, reason error) bool
	PutHash(id ID, peers []HashPeer, options ...HashOption) btree.PutResult
}

type TableOrigin

type TableOrigin interface {
	Origin() ID
}

type TableQuery

type TableQuery interface {
	GetClosestNodes(id ID) []Node
	GetOldestNodes(cutoff time.Time, n int) []Node
	GetNodesForSampleInfoHashes(n int) []Node
	FilterKnownAddrs(addrs []netip.Addr) []netip.Addr
	GetHashOrClosestNodes(id ID) GetHashOrClosestNodesResult
	// SampleHashesAndNodes returns a random sample of up to 8 hashes and nodes, and the total hashes count.
	SampleHashesAndNodes() SampleHashesAndNodesResult
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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