Documentation ¶
Index ¶
- type Operation
- func (op *Operation) AddNode(n types.AddrMaybeId) (err error)
- func (op *Operation) AddNodes(nodes []types.AddrMaybeId) (added int)
- func (op *Operation) Closest() *k_nearest_nodes.Type
- func (op *Operation) Stalled() events.Active
- func (op *Operation) Stats() *Stats
- func (op *Operation) Stop()
- func (op *Operation) Stopped() events.Done
- type OperationInput
- type QueryResult
- type Stats
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) AddNode ¶ added in v2.21.0
func (op *Operation) AddNode(n types.AddrMaybeId) (err error)
Add an unqueried node returning an error with a reason why the node wasn't added.
func (*Operation) AddNodes ¶
func (op *Operation) AddNodes(nodes []types.AddrMaybeId) (added int)
Add a bunch of unqueried nodes at once, returning how many were successfully added.
func (*Operation) Closest ¶
func (op *Operation) Closest() *k_nearest_nodes.Type
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 }
Click to show internal directories.
Click to hide internal directories.