providerquerymanager

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: Apache-2.0, MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// DefaultMaxInProcessRequests is the default maximum number of requests
	// that are processed concurrently. A value of 0 means unlimited.
	DefaultMaxInProcessRequests = 8
	// DefaultMaxProviders is the default maximum number of providers that are
	// looked up per find request. 0 value means unlimited.
	DefaultMaxProviders = 0
	// DefaultTimeout is the limit on the amount of time to spend waiting for
	// the maximum number of providers from a find request.
	DefaultTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*ProviderQueryManager) error

func WithIgnoreProviders added in v0.29.0

func WithIgnoreProviders(peers ...peer.ID) Option

WithIgnoreProviders will ignore provider records from the given peers.

func WithMaxInProcessRequests

func WithMaxInProcessRequests(count int) Option

WithMaxInProcessRequests sets maximum number of requests that are processed concurrently. A value of 0 means unlimited. Default is DefaultMaxInProcessRequests.

func WithMaxProviders

func WithMaxProviders(count int) Option

WithMaxProviders sets the maximum number of providers that are looked up per find request. Only providers that we can connect to are returned. Defaults to 0, which means unlimited.

func WithMaxTimeout

func WithMaxTimeout(timeout time.Duration) Option

WithMaxTimeout sets the limit on the amount of time to spend waiting for the maximum number of providers from a find request.

type ProviderQueryDialer

type ProviderQueryDialer interface {
	Connect(context.Context, peer.AddrInfo) error
}

ProviderQueryDialer is an interface for connecting to peers. Usually a libp2p.Host

type ProviderQueryManager

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

ProviderQueryManager manages requests to find more providers for blocks for bitswap sessions. It's main goals are to: - rate limit requests -- don't have too many find provider calls running simultaneously - connect to found peers and filter them if it can't connect - ensure two findprovider calls for the same block don't run concurrently - manage timeouts

func New

New initializes a new ProviderQueryManager for a given context and a given network provider.

func (*ProviderQueryManager) Close

func (pqm *ProviderQueryManager) Close()

func (*ProviderQueryManager) FindProvidersAsync

func (pqm *ProviderQueryManager) FindProvidersAsync(sessionCtx context.Context, k cid.Cid, max int) <-chan peer.AddrInfo

FindProvidersAsync finds providers for the given block. The max parameter controls how many will be returned at most. For a provider to be returned, we must have successfully connected to it. Setting max to 0 will use the configured MaxProviders which defaults to 0 (unbounded).

Jump to

Keyboard shortcuts

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