providerquerymanager

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0, MIT Imports: 13 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*ProviderQueryManager) error

func WithMaxInProcessRequests

func WithMaxInProcessRequests(count int) Option

WithMaxInProcessRequests is the maximum number of requests that can be processed in parallel. If this is 0, then the number is unlimited. Default is defaultMaxInProcessRequests (16).

func WithMaxProviders

func WithMaxProviders(count int) Option

WithMaxProviders is the maximum number of providers that will be looked up per query. We only return providers that we can connect to. Defaults to 0, which means unbounded.

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).

type ProviderQueryRouter

type ProviderQueryRouter interface {
	FindProvidersAsync(context.Context, cid.Cid, int) <-chan peer.AddrInfo
}

ProviderQueryRouter is an interface for finding providers. Usually a libp2p ContentRouter.

Jump to

Keyboard shortcuts

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