provider

package module
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0, MIT Imports: 2 Imported by: 35

README

go-ipfs-provider

Coverage Status Travis CI

❗ This repo is no longer maintained.

👉 We highly recommend switching to the maintained version at https://github.com/ipfs/boxo/tree/main/provider. 🏎️ Good news! There is tooling and documentation to expedite a switch in your repo.

⚠️ If you continue using this repo, please note that security fixes will not be provided (unless someone steps in to maintain it).

📚 Learn more, including how to take the maintainership mantle or ask questions, here.

Background

The provider system is responsible for announcing and reannouncing to the ipfs network that a node has content.

Install

Via go get:

$ go get github.com/ipfs/go-ipfs-provider

Requires Go 1.12

Usage

Here's how you create, start, interact with, and stop the provider system:

import (
	"context"
	"time"

	"github.com/ipfs/go-ipfs-provider"
	"github.com/ipfs/go-ipfs-provider/queue"
	"github.com/ipfs/go-ipfs-provider/simple"
)

rsys := (your routing system here)
dstore := (your datastore here)
cid := (your cid to provide here)

q := queue.NewQueue(context.Background(), "example", dstore)

reprov := simple.NewReprovider(context.Background(), time.Hour * 12, rsys, simple.NewBlockstoreProvider(dstore))
prov := simple.NewProvider(context.Background(), q, rsys)
sys := provider.NewSystem(prov, reprov)

sys.Run()

sys.Provide(cid)

sys.Close()

License

This library is dual-licensed under Apache 2.0 and MIT terms.

Copyright 2019. Protocol Labs, Inc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider deprecated

type Provider interface {
	// Run is used to begin processing the provider work
	Run()
	// Provide takes a cid and makes an attempt to announce it to the network
	Provide(cid.Cid) error
	// Close stops the provider
	Close() error
}

Provider announces blocks to the network

Deprecated: use github.com/ipfs/boxo/provider.Provider

type Reprovider deprecated

type Reprovider interface {
	// Run is used to begin processing the reprovider work and waiting for reprovide triggers
	Run()
	// Trigger a reprovide
	Trigger(context.Context) error
	// Close stops the reprovider
	Close() error
}

Reprovider reannounces blocks to the network

Deprecated: use github.com/ipfs/boxo/provider.Reprovider

type System deprecated

type System interface {
	Run()
	Close() error
	Provide(cid.Cid) error
	Reprovide(context.Context) error
}

System defines the interface for interacting with the value provider system

Deprecated: use github.com/ipfs/boxo/provider.System

func NewOfflineProvider deprecated

func NewOfflineProvider() System

NewOfflineProvider creates a ProviderSystem that does nothing

Deprecated: use github.com/ipfs/boxo/provider.NewOfflineProvider

func NewSystem deprecated

func NewSystem(provider Provider, reprovider Reprovider) System

NewSystem constructs a new provider system from a provider and reprovider

Deprecated: use github.com/ipfs/boxo/provider.NewSystem

Directories

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

Jump to

Keyboard shortcuts

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