@cryptotaxi247 / kubo / commits / 0b1276db5

Use datastore based pinner

Adin Schmahmann committed Dec 4, 2020 at 15:28 UTC 0b1276db596e9d1cfdf1bc584f8ee3344a76910d
3 files changed +10 -12
core/node/core.go
+7 -9
@@ -3,6 +3,7 @@ package node
3 import (
4 "context"
5 "fmt"
6 + "time"
7
8 "github.com/ipfs/go-bitswap"
9 "github.com/ipfs/go-bitswap/network"
@@ -12,8 +13,8 @@ import (
13 "github.com/ipfs/go-filestore"
14 "github.com/ipfs/go-ipfs-blockstore"
15 "github.com/ipfs/go-ipfs-exchange-interface"
15 - "github.com/ipfs/go-ipfs-exchange-offline"
16 "github.com/ipfs/go-ipfs-pinner"
17 + "github.com/ipfs/go-ipfs-pinner/dspinner"
18 "github.com/ipfs/go-ipld-format"
19 "github.com/ipfs/go-merkledag"
20 "github.com/ipfs/go-mfs"
@@ -41,7 +42,6 @@ func BlockService(lc fx.Lifecycle, bs blockstore.Blockstore, rem exchange.Interf
42
43 // Pinning creates new pinner which tells GC which blocks should be kept
44 func Pinning(bstore blockstore.Blockstore, ds format.DAGService, repo repo.Repo) (pin.Pinner, error) {
44 - internalDag := merkledag.NewDAGService(blockservice.New(bstore, offline.Exchange(bstore)))
45 rootDS := repo.Datastore()
46
47 syncFn := func() error {
@@ -51,15 +51,13 @@ func Pinning(bstore blockstore.Blockstore, ds format.DAGService, repo repo.Repo)
51 return rootDS.Sync(filestore.FilestorePrefix)
52 }
53 syncDs := &syncDagService{ds, syncFn}
54 - syncInternalDag := &syncDagService{internalDag, syncFn}
54
56 - pinning, err := pin.LoadPinner(rootDS, syncDs, syncInternalDag)
55 + ctx, cancel := context.WithTimeout(context.TODO(), 2*time.Minute)
56 + defer cancel()
57 +
58 + pinning, err := dspinner.New(ctx, rootDS, syncDs)
59 if err != nil {
58 - // TODO: we should move towards only running 'NewPinner' explicitly on
59 - // node init instead of implicitly here as a result of the pinner keys
60 - // not being found in the datastore.
61 - // this is kinda sketchy and could cause data loss
62 - pinning = pin.NewPinner(rootDS, syncDs, syncInternalDag)
60 + return nil, err
61 }
62
63 return pinning, nil
go.mod
+1 -1
@@ -36,7 +36,7 @@ require (
36 github.com/ipfs/go-ipfs-exchange-interface v0.0.1
37 github.com/ipfs/go-ipfs-exchange-offline v0.0.1
38 github.com/ipfs/go-ipfs-files v0.0.8
39 - github.com/ipfs/go-ipfs-pinner v0.0.4
39 + github.com/ipfs/go-ipfs-pinner v0.1.0
40 github.com/ipfs/go-ipfs-posinfo v0.0.1
41 github.com/ipfs/go-ipfs-provider v0.4.3
42 github.com/ipfs/go-ipfs-routing v0.1.0
go.sum
+2 -2
@@ -388,8 +388,8 @@ github.com/ipfs/go-ipfs-files v0.0.3/go.mod h1:INEFm0LL2LWXBhNJ2PMIIb2w45hpXgPjN
388 github.com/ipfs/go-ipfs-files v0.0.8 h1:8o0oFJkJ8UkO/ABl8T6ac6tKF3+NIpj67aAB6ZpusRg=
389 github.com/ipfs/go-ipfs-files v0.0.8/go.mod h1:wiN/jSG8FKyk7N0WyctKSvq3ljIa2NNTiZB55kpTdOs=
390 github.com/ipfs/go-ipfs-flags v0.0.1/go.mod h1:RnXBb9WV53GSfTrSDVK61NLTFKvWc60n+K9EgCDh+rA=
391 -github.com/ipfs/go-ipfs-pinner v0.0.4 h1:EmxhS3vDsCK/rZrsgxX0Le9m2drBcGlUd7ah/VyFYVE=
392 -github.com/ipfs/go-ipfs-pinner v0.0.4/go.mod h1:s4kFZWLWGDudN8Jyd/GTpt222A12C2snA2+OTdy/7p8=
391 +github.com/ipfs/go-ipfs-pinner v0.1.0 h1:rjSrbUDYd1YYHZ5dOgu+QEOuLcU0m/2a/brcxC/ReeU=
392 +github.com/ipfs/go-ipfs-pinner v0.1.0/go.mod h1:EzyyaWCWeZJ/he9cDBH6QrEkSuRqTRWMmCoyNkylTTg=
393 github.com/ipfs/go-ipfs-posinfo v0.0.1 h1:Esoxj+1JgSjX0+ylc0hUmJCOv6V2vFoZiETLR6OtpRs=
394 github.com/ipfs/go-ipfs-posinfo v0.0.1/go.mod h1:SwyeVP+jCwiDu0C313l/8jg6ZxM0qqtlt2a0vILTc1A=
395 github.com/ipfs/go-ipfs-pq v0.0.1/go.mod h1:LWIqQpqfRG3fNc5XsnIhz/wQ2XXGyugQwls7BgUmUfY=