Skip to content

Commit

Permalink
Refactor to create strategy with pin.Pinner dependency within go-ipfs
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelavila committed Jun 10, 2019
1 parent 561616f commit 1df47b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
13 changes: 11 additions & 2 deletions core/node/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ import (
"fmt"
"time"

"github.com/ipfs/go-ipfs/pin"

"github.com/ipfs/go-ipfs-provider"
q "github.com/ipfs/go-ipfs-provider/queue"
"github.com/ipfs/go-ipfs-provider/simple"
"github.com/ipfs/go-ipfs/core/node/helpers"
"github.com/ipfs/go-ipfs/repo"
ipld "github.com/ipfs/go-ipld-format"
"github.com/libp2p/go-libp2p-core/routing"
"go.uber.org/fx"
)
Expand Down Expand Up @@ -101,9 +104,9 @@ func SimpleProviders(reprovideStrategy string, reprovideInterval string) fx.Opti
case "":
keyProvider = fx.Provide(simple.NewBlockstoreProvider)
case "roots":
keyProvider = fx.Provide(simple.NewPinnedProvider(true))
keyProvider = fx.Provide(PinnedProviderStrategy(true))
case "pinned":
keyProvider = fx.Provide(simple.NewPinnedProvider(false))
keyProvider = fx.Provide(PinnedProviderStrategy(false))
default:
return fx.Error(fmt.Errorf("unknown reprovider strategy '%s'", reprovideStrategy))
}
Expand All @@ -115,3 +118,9 @@ func SimpleProviders(reprovideStrategy string, reprovideInterval string) fx.Opti
fx.Provide(SimpleReprovider(reproviderInterval)),
)
}

func PinnedProviderStrategy(onlyRoots bool) interface{} {
return func(pinner pin.Pinner, dag ipld.DAGService) simple.KeyChanFunc {
return simple.NewPinnedProvider(onlyRoots, pinner, dag)
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ require (
github.com/ipfs/go-ipfs-exchange-offline v0.0.1
github.com/ipfs/go-ipfs-files v0.0.3
github.com/ipfs/go-ipfs-posinfo v0.0.1
github.com/ipfs/go-ipfs-provider v0.0.0-20190606214637-245e9651e80d
github.com/ipfs/go-ipfs-provider v0.0.0-20190610184752-d7bb85e89013
github.com/ipfs/go-ipfs-routing v0.1.0
github.com/ipfs/go-ipfs-util v0.0.1
github.com/ipfs/go-ipld-cbor v0.0.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ github.com/ipfs/go-ipfs-provider v0.0.0-20190601062352-095af8f253ae h1:5ClijX79U
github.com/ipfs/go-ipfs-provider v0.0.0-20190601062352-095af8f253ae/go.mod h1:Zbv9hdJ0m+MpafEK1FKtBUO2LbSONSw3/OMzzkx4SIY=
github.com/ipfs/go-ipfs-provider v0.0.0-20190606214637-245e9651e80d h1:05Qz5fw6UA5Mj6E04R0Yvrh0hls+y1Y5nAdZelskiAk=
github.com/ipfs/go-ipfs-provider v0.0.0-20190606214637-245e9651e80d/go.mod h1:r8PN9I9dKakIm6zcBwLtVtTSO29WvHlUrCp9umHhhp0=
github.com/ipfs/go-ipfs-provider v0.0.0-20190610184752-d7bb85e89013 h1:Jsln/7WIxgb6zxs2r4gFXVOVNMxGPbUp38e+7eCcdfc=
github.com/ipfs/go-ipfs-provider v0.0.0-20190610184752-d7bb85e89013/go.mod h1:r8PN9I9dKakIm6zcBwLtVtTSO29WvHlUrCp9umHhhp0=
github.com/ipfs/go-ipfs-routing v0.0.1/go.mod h1:k76lf20iKFxQTjcJokbPM9iBXVXVZhcOwc360N4nuKs=
github.com/ipfs/go-ipfs-routing v0.1.0 h1:gAJTT1cEeeLj6/DlLX6t+NxD9fQe2ymTO6qWRDI/HQQ=
github.com/ipfs/go-ipfs-routing v0.1.0/go.mod h1:hYoUkJLyAUKhF58tysKpids8RNDPO42BVMgK5dNsoqY=
Expand Down

0 comments on commit 1df47b1

Please sign in to comment.