The provider system is responsible for announcing and reannouncing to the ipfs network that a node has content.
Via go get
:
$ go get github.com/ipfs/go-ipfs-provider
Requires Go 1.12
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()
PRs are welcome!
Small note: If editing the Readme, please conform to the standard-readme specification.
This library is dual-licensed under Apache 2.0 and MIT terms.
Copyright 2019. Protocol Labs, Inc.