Documentation
¶
Index ¶
Constants ¶
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
WithIgnoreProviders will ignore provider records from the given peers.
func WithMaxInProcessRequests ¶
WithMaxInProcessRequests sets maximum number of requests that are processed concurrently. A value of 0 means unlimited. Default is DefaultMaxInProcessRequests.
func WithMaxProviders ¶
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 ¶
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 routing.ContentDiscovery, 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).