crawler

package
v0.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: MIT Imports: 12 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crawler

type Crawler interface {
	// Run crawls the DHT starting from the startingPeers, and calls either handleSuccess or handleFail depending on whether a peer was successfully contacted or not.
	Run(ctx context.Context, startingPeers []*peer.AddrInfo, handleSuccess HandleQueryResult, handleFail HandleQueryFail)
}

Crawler connects to hosts in the DHT to track routing tables of peers.

type DefaultCrawler added in v0.22.0

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

DefaultCrawler provides a default implementation of Crawler.

func NewDefaultCrawler added in v0.22.0

func NewDefaultCrawler(host host.Host, opts ...Option) (*DefaultCrawler, error)

NewDefaultCrawler creates a new DefaultCrawler

func (*DefaultCrawler) Run added in v0.22.0

func (c *DefaultCrawler) Run(ctx context.Context, startingPeers []*peer.AddrInfo, handleSuccess HandleQueryResult, handleFail HandleQueryFail)

Run crawls dht peers from an initial seed of `startingPeers`

type HandleQueryFail

type HandleQueryFail func(p peer.ID, err error)

HandleQueryFail is a callback on failed peer query

type HandleQueryResult

type HandleQueryResult func(p peer.ID, rtPeers []*peer.AddrInfo)

HandleQueryResult is a callback on successful peer query

type Option

type Option func(*options) error

Option DHT Crawler option type.

func WithConnectTimeout

func WithConnectTimeout(timeout time.Duration) Option

WithConnectTimeout defines the time for peer connection before timing out

func WithDialAddrExtendDuration added in v0.22.0

func WithDialAddrExtendDuration(ext time.Duration) Option

WithDialAddrExtendDuration sets the duration by which the TTL of dialed address in peer store are extended. Defaults to 30 minutes if unset.

func WithMsgTimeout

func WithMsgTimeout(timeout time.Duration) Option

WithMsgTimeout defines the amount of time a single DHT message is allowed to take before it's deemed failed

func WithParallelism

func WithParallelism(parallelism int) Option

WithParallelism defines the number of queries that can be issued in parallel

func WithProtocols

func WithProtocols(protocols []protocol.ID) Option

WithProtocols defines the ordered set of protocols the crawler will use to talk to other nodes

Jump to

Keyboard shortcuts

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