traversal

package
v2.0.0-...-be9fe6b Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2023 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Operation

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

func Start

func Start(input OperationInput) *Operation

func (*Operation) AddNodes

func (op *Operation) AddNodes(nodes []types.AddrMaybeId) (added int)

func (*Operation) Closest

func (op *Operation) Closest() *k_nearest_nodes.Type

func (*Operation) Stalled

func (op *Operation) Stalled() events.Active

func (*Operation) Stats

func (op *Operation) Stats() *Stats

I don't think you should access this until the Stopped event.

func (*Operation) Stop

func (op *Operation) Stop()

func (*Operation) Stopped

func (op *Operation) Stopped() events.Done

type OperationInput

type OperationInput struct {
	Target     krpc.ID
	Alpha      int
	K          int
	DoQuery    func(context.Context, krpc.NodeAddr) QueryResult
	NodeFilter func(types.AddrMaybeId) bool
	// This filters the adding of nodes to the "closest data" set based on the data they provided.
	// The data is (usually?) derived from the token field in a reply. For the get_peers traversal
	// operation for example, we would filter out non-strings, since we later need to pass strings
	// in to the Token field to announce ourselves to the closest nodes we found to the target.
	DataFilter func(data any) bool
}

type QueryResult

type QueryResult struct {
	// This is set non-nil if a query reply is a response-type as defined by the DHT BEP 5 (contains
	// "r")
	ResponseFrom *krpc.NodeInfo
	// Data associated with a closest node. Is this ever not a string? I think using generics for
	// this leaks throughout the entire Operation. Hardly worth it. It's still possible to handle
	// invalid token types at runtime.
	ClosestData interface{}
	Nodes       []krpc.NodeInfo
	Nodes6      []krpc.NodeInfo
}

type Stats

type Stats struct {
	// Count of (probably) distinct addresses we've sent traversal queries to. Accessed with atomic.
	NumAddrsTried uint32
	// Number of responses we received to queries related to this traversal. Accessed with atomic.
	NumResponses uint32
}

Jump to

Keyboard shortcuts

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