GithubHelp home page GithubHelp logo

go-ipfs-provider's Introduction

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.

go-ipfs-provider's People

Contributors

acruikshank avatar aschmahmann avatar djdv avatar galargh avatar guseggert avatar hacdias avatar hsanjuan avatar ipfs-mgmt-read-write[bot] avatar jorropo avatar marten-seemann avatar michaelavila avatar michaelmure avatar raulk avatar stebalien avatar web-flow avatar web3-bot avatar willscott avatar zeigo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-ipfs-provider's Issues

Concurrent republishing ?

Unless I missed something, this package does only sequential republishing and thus is quite slow.

Would it make sense to have concurrent republishing ? Any constraint I should be aware of ?

Strange Behavior With Provider Correlated With Long Running Contexts

Currently, when instantiating the provider a context is passed in. This context is then used internally when providing records to the network.

In my usage of this library, the context that gets passed in during initialization is never cancelled until my custom node service stops. The issue appears to be that if the context being used when providing a record to the network never cancels, then the provide call doesn't actually complete. This has lead to strange behaviour that I've noticed if I'm starting+stopping my custom node multiple times, using different peerID's each time. And seemingly each time the node "starts", records that were previously being announced to the network started showing up.

Digging a little further this isn't actually the case. What's happening is that only when the node service stops, is the context cancelled, thus triggering the Provide call to finish.

Digging a little further, I forked the repository to introduce some custom behaviour which is to initialize a temporary context with a timeout of 1 minute. By doing this, records will be provided to the network as expected and everything is okay.

So the root of the issue appears to be that records aren't actually being provided to the network, until the context that's passed into the Provide call is cancelled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.