provider

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MAGIC: how long we wait before reproviding a key
	DefaultReproviderInterval = time.Hour * 22 // https://github.com/ipfs/kubo/pull/9326

)

Variables

View Source
var DefaultKeyPrefix = datastore.NewKey("/provider")

Functions

This section is empty.

Types

type KeyChanFunc

type KeyChanFunc func(context.Context) (<-chan cid.Cid, error)

KeyChanFunc is function streaming CIDs to pass to content routing

func NewBlockstoreProvider

func NewBlockstoreProvider(bstore blocks.Blockstore) KeyChanFunc

NewBlockstoreProvider returns key provider using bstore.AllKeysChan

func NewPinnedProvider

func NewPinnedProvider(onlyRoots bool, pinning pin.Pinner, fetchConfig fetcher.Factory) KeyChanFunc

NewPinnedProvider returns provider supplying pinned keys

type Option

type Option func(system *reprovider) error

Option defines the functional option type that can be used to configure BatchProvidingSystem instances

func DatastorePrefix

func DatastorePrefix(k datastore.Key) Option

DatastorePrefix sets a prefix for internal state stored in the Datastore. Defaults to DefaultKeyPrefix.

func KeyProvider

func KeyProvider(fn KeyChanFunc) Option

func Online

func Online(rsys Provide) Option

Online will enable the router and make it send publishes online. nil can be used to turn the router offline. You can't register multiple providers, if this option is passed multiple times it will error.

func ReproviderInterval

func ReproviderInterval(duration time.Duration) Option

func ThroughputReport

func ThroughputReport(f ThroughputCallback, minimumProvides uint) Option

ThroughputReport will fire the callback synchronously once at least limit multihashes have been advertised, it will then wait until a new set of at least limit multihashes has been advertised. While ThroughputReport is set batches will be at most minimumProvides big. If it returns false it wont ever be called again.

type Provide

type Provide interface {
	Provide(context.Context, cid.Cid, bool) error
}

type ProvideMany

type ProvideMany interface {
	ProvideMany(ctx context.Context, keys []multihash.Multihash) error
}

type Provider

type Provider interface {
	// Provide takes a cid and makes an attempt to announce it to the network
	Provide(cid.Cid) error
}

Provider announces blocks to the network

type Ready

type Ready interface {
	Ready() bool
}

type Reprovider

type Reprovider interface {
	// Reprovide starts a new reprovide if one isn't running already.
	Reprovide(context.Context) error
}

Reprovider reannounces blocks to the network

type ReproviderStats

type ReproviderStats struct {
	TotalProvides, LastReprovideBatchSize     uint64
	AvgProvideDuration, LastReprovideDuration time.Duration
}

type System

type System interface {
	Close() error
	Stat() (ReproviderStats, error)
	Provider
	Reprovider
}

System defines the interface for interacting with the value provider system

func New

func New(ds datastore.Batching, opts ...Option) (System, error)

New creates a new System. By default it is offline, that means it will enqueue tasks in ds. To have it publish records in the network use the Online option. If provider casts to ProvideMany the [ProvideMany.ProvideMany] method will be called instead.

If provider casts to Ready, it will wait until [Ready.Ready] is true.

func NewNoopProvider

func NewNoopProvider() System

NewNoopProvider creates a ProviderSystem that does nothing.

type ThroughputCallback

type ThroughputCallback = func(reprovide bool, complete bool, totalKeysProvided uint, totalDuration time.Duration) (continueWatching bool)

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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