simple

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT, Apache-2.0, MIT Imports: 14 Imported by: 0

Documentation

Overview

Package simple implements structures and methods to provide blocks, keep track of which blocks are provided, and to allow those blocks to be reprovided.

Index

Constants

This section is empty.

Variables

View Source
var ErrClosed = errors.New("reprovider service stopped")

ErrClosed is returned by Trigger when operating on a closed reprovider.

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 Pinner, dag ipld.DAGService) KeyChanFunc

NewPinnedProvider returns provider supplying pinned keys

type Option

type Option func(*Provider)

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

func MaxWorkers

func MaxWorkers(count int) Option

MaxWorkers is an option to set the max workers on a provider

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout is an option to set a timeout on a provider

type Pinner

type Pinner interface {
	DirectKeys(ctx context.Context) ([]cid.Cid, error)
	RecursiveKeys(ctx context.Context) ([]cid.Cid, error)
}

Pinner interface defines how the simple.Reprovider wants to interact with a Pinning service

type Provider

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

Provider announces blocks to the network

func NewProvider

func NewProvider(ctx context.Context, queue *q.Queue, contentRouting routing.ContentRouting, options ...Option) *Provider

NewProvider creates a provider that announces blocks to the network using a content router

func (*Provider) Close

func (p *Provider) Close() error

Close stops the provider

func (*Provider) Provide

func (p *Provider) Provide(root cid.Cid) error

Provide the given cid using specified strategy.

func (*Provider) Run

func (p *Provider) Run()

Run workers to handle provide requests.

type Reprovider

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

Reprovider reannounces blocks to the network

func NewReprovider

func NewReprovider(ctx context.Context, reprovideIniterval time.Duration, rsys routing.ContentRouting, keyProvider KeyChanFunc) *Reprovider

NewReprovider creates new Reprovider instance.

func (*Reprovider) Close

func (rp *Reprovider) Close() error

Close the reprovider

func (*Reprovider) Reprovide

func (rp *Reprovider) Reprovide() error

Reprovide registers all keys given by rp.keyProvider to libp2p content routing

func (*Reprovider) Run

func (rp *Reprovider) Run()

Run re-provides keys with 'tick' interval or when triggered

func (*Reprovider) Trigger

func (rp *Reprovider) Trigger(ctx context.Context) error

Trigger starts the reprovision process in rp.Run and waits for it to finish.

Returns an error if a reprovide is already in progress.

Jump to

Keyboard shortcuts

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