README.md 1.75 KB
Newer Older
Michael Avila's avatar
Michael Avila committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
# go-ipfs-provider

[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai)
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs)
[![Coverage Status](https://codecov.io/gh/ipfs/go-ipfs-provider/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/go-ipfs-provider)
[![Travis CI](https://travis-ci.org/ipfs/go-ipfs-provider.svg?branch=master)](https://travis-ci.org/ipfs/go-ipfs-provider)

## Background

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

## Install

Via `go get`:

```sh
$ 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:

```golang
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)

43
reprov := simple.NewReprovider(context.Background(), time.Hour * 12, rsys, simple.NewBlockstoreProvider(dstore))
Michael Avila's avatar
Michael Avila committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
prov := simple.NewProvider(context.Background(), q, rsys)
sys := provider.NewSystem(prov, reprov)

sys.Run()

sys.Provide(cid)

sys.Close()
```

## Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.

## License

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

Copyright 2019. Protocol Labs, Inc.