traversal2

package
v0.0.0-...-1d901b0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MPL-2.0, MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Traversal)

Option configures a Traversal.

func WithK

func WithK(k int) Option

WithK sets the maximum number of closest nodes to track.

func WithQueryTimeout

func WithQueryTimeout(d time.Duration) Option

WithQueryTimeout sets the per-query timeout.

func WithSeeds

func WithSeeds(nodes ...krpc.NodeInfo) Option

WithSeeds adds initial nodes to query.

type Querier

type Querier interface {
	Query(ctx context.Context, addr krpc.NodeAddr, target int160.T, scrape bool) QueryResult
}

Querier executes a query against a DHT node.

type QueryResult

type QueryResult struct {
	IP           netip.AddrPort
	ResponseFrom *krpc.NodeInfo
	Nodes        []krpc.NodeInfo
	Peers        []krpc.NodeAddr
}

QueryResult contains the response from a DHT query.

type Traversal

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

Traversal performs a DHT traversal toward a target, yielding peers found.

func New

func New(target int160.T, querier Querier, opts ...Option) *Traversal

New creates a new Traversal.

func (*Traversal) Each

func (t *Traversal) Each(ctx context.Context) iter.Seq[krpc.NodeAddr]

Each returns an iterator that yields peers found during traversal.

func (*Traversal) Err

func (t *Traversal) Err() error

Err returns any error encountered during iteration.

func (*Traversal) Results

func (t *Traversal) Results(ctx context.Context) iter.Seq[QueryResult]

Each returns an iterator that yields peers found during traversal.

Jump to

Keyboard shortcuts

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