@@ -9,11 +9,11 @@ import (
9
9
"github.com/cenkalti/backoff"
10
10
"github.com/ipfs/go-cid"
11
11
"github.com/ipfs/go-cidutil"
12
+ "github.com/ipfs/go-fetcher"
12
13
blocks "github.com/ipfs/go-ipfs-blockstore"
13
- ipld "github.com/ipfs/go-ipld-format"
14
14
logging "github.com/ipfs/go-log"
15
- "github.com/ipfs/go-merkledag"
16
15
"github.com/ipfs/go-verifcid"
16
+ cidlink "github.com/ipld/go-ipld-prime/linking/cid"
17
17
"github.com/libp2p/go-libp2p-core/routing"
18
18
)
19
19
@@ -184,9 +184,9 @@ type Pinner interface {
184
184
}
185
185
186
186
// NewPinnedProvider returns provider supplying pinned keys
187
- func NewPinnedProvider (onlyRoots bool , pinning Pinner , dag ipld. DAGService ) KeyChanFunc {
187
+ func NewPinnedProvider (onlyRoots bool , pinning Pinner , fetchConfig fetcher. FetcherConfig ) KeyChanFunc {
188
188
return func (ctx context.Context ) (<- chan cid.Cid , error ) {
189
- set , err := pinSet (ctx , pinning , dag , onlyRoots )
189
+ set , err := pinSet (ctx , pinning , fetchConfig , onlyRoots )
190
190
if err != nil {
191
191
return nil , err
192
192
}
@@ -208,7 +208,7 @@ func NewPinnedProvider(onlyRoots bool, pinning Pinner, dag ipld.DAGService) KeyC
208
208
}
209
209
}
210
210
211
- func pinSet (ctx context.Context , pinning Pinner , dag ipld. DAGService , onlyRoots bool ) (* cidutil.StreamingSet , error ) {
211
+ func pinSet (ctx context.Context , pinning Pinner , fetchConfig fetcher. FetcherConfig , onlyRoots bool ) (* cidutil.StreamingSet , error ) {
212
212
set := cidutil .NewStreamingSet ()
213
213
214
214
go func () {
@@ -230,11 +230,18 @@ func pinSet(ctx context.Context, pinning Pinner, dag ipld.DAGService, onlyRoots
230
230
logR .Errorf ("reprovide indirect pins: %s" , err )
231
231
return
232
232
}
233
+
234
+ session := fetchConfig .NewSession (ctx )
233
235
for _ , key := range rkeys {
234
- if onlyRoots {
235
- set .Visitor (ctx )(key )
236
- } else {
237
- err := merkledag .Walk (ctx , merkledag .GetLinksWithDAG (dag ), key , set .Visitor (ctx ))
236
+ set .Visitor (ctx )(key )
237
+ if ! onlyRoots {
238
+ err := fetcher .BlockAll (ctx , session , cidlink.Link {key }, func (res fetcher.FetchResult ) error {
239
+ clink , ok := res .LastBlockLink .(cidlink.Link )
240
+ if ok {
241
+ set .Visitor (ctx )(clink .Cid )
242
+ }
243
+ return nil
244
+ })
238
245
if err != nil {
239
246
logR .Errorf ("reprovide indirect pins: %s" , err )
240
247
return
0 commit comments