providers

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: 18 Imported by: 40

Documentation

Index

Constants

View Source
const (
	// ProvidersKeyPrefix is the prefix/namespace for ALL provider record
	// keys stored in the data store.
	ProvidersKeyPrefix = "/providers/"

	// ProviderAddrTTL is the TTL to keep the multi addresses of provider
	// peers around. Those addresses are returned alongside provider. After
	// it expires, the returned records will require an extra lookup, to
	// find the multiaddress associated with the returned peer id.
	ProviderAddrTTL = amino.DefaultProviderAddrTTL
)

Variables

View Source
var ProvideValidity = amino.DefaultProvideValidity

ProvideValidity is the default time that a Provider Record should last on DHT This value is also known as Provider Record Expiration Interval.

Functions

This section is empty.

Types

type Option added in v0.7.6

type Option func(*ProviderManager) error

Option is a function that sets a provider manager option.

func Cache added in v0.7.6

func Cache(c lru.LRUCache) Option

Cache sets the LRU cache implementation. Defaults to a simple LRU cache.

func CleanupInterval added in v0.7.6

func CleanupInterval(d time.Duration) Option

CleanupInterval sets the time between GC runs. Defaults to 1h.

type ProviderManager

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

ProviderManager adds and pulls providers out of the datastore, caching them in between

func NewProviderManager

func NewProviderManager(local peer.ID, ps peerstore.Peerstore, dstore ds.Batching, opts ...Option) (*ProviderManager, error)

NewProviderManager constructor

func (*ProviderManager) AddProvider

func (pm *ProviderManager) AddProvider(ctx context.Context, k []byte, provInfo peer.AddrInfo) error

AddProvider adds a provider

func (*ProviderManager) Close added in v0.24.1

func (pm *ProviderManager) Close() error

func (*ProviderManager) GetProviders

func (pm *ProviderManager) GetProviders(ctx context.Context, k []byte) ([]peer.AddrInfo, error)

GetProviders returns the set of providers for the given key. This method _does not_ copy the set. Do not modify it.

type ProviderStore added in v0.14.0

type ProviderStore interface {
	AddProvider(ctx context.Context, key []byte, prov peer.AddrInfo) error
	GetProviders(ctx context.Context, key []byte) ([]peer.AddrInfo, error)
	io.Closer
}

ProviderStore represents a store that associates peers and their addresses to keys.

Jump to

Keyboard shortcuts

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