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 ¶
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 ¶
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 ¶
WithMaxTimeout sets the limit on the amount of time to spend waiting for the maximum number of providers from a find request.
type ProviderQueryDialer ¶
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 ¶
func New(dialer ProviderQueryDialer, router ProviderQueryRouter, opts ...Option) (*ProviderQueryManager, error)
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).