Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-provider
Commits
7463091a
Unverified
Commit
7463091a
authored
Mar 17, 2021
by
Alex Cruikshank
Committed by
GitHub
Mar 17, 2021
1
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #30 from ipfs/feat/use_ipld_prime
replace go-merkledag with go-fetcher
parents
b8fd93c8
28506e1a
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
525 additions
and
28 deletions
+525
-28
.travis.yml
.travis.yml
+1
-1
go.mod
go.mod
+12
-11
go.sum
go.sum
+492
-4
simple/reprovide.go
simple/reprovide.go
+16
-9
simple/reprovide_test.go
simple/reprovide_test.go
+4
-3
No files found.
.travis.yml
View file @
7463091a
...
...
@@ -4,7 +4,7 @@ os:
language
:
go
go
:
-
1.1
1
.x
-
1.1
3
.x
env
:
global
:
...
...
go.mod
View file @
7463091a
module
github.com/ipfs/go-ipfs-provider
go 1.1
2
go 1.1
3
require (
github.com/cenkalti/backoff
v2.2.1+incompatible
github.com/ipfs/go-blockservice
v0.1.
2
github.com/ipfs/go-cid
v0.0.
3
github.com/ipfs/go-blockservice
v0.1.
4
github.com/ipfs/go-cid
v0.0.
7
github.com/ipfs/go-cidutil
v0.0.2
github.com/ipfs/go-datastore
v0.1.0
github.com/ipfs/go-ipfs-blockstore
v0.1.0
github.com/ipfs/go-datastore
v0.4.5
github.com/ipfs/go-fetcher
v1.1.0
github.com/ipfs/go-ipfs-blockstore
v0.1.4
github.com/ipfs/go-ipfs-blocksutil
v0.0.1
github.com/ipfs/go-ipfs-exchange-offline
v0.0.1
github.com/ipfs/go-ipfs-routing
v0.1.0
github.com/ipfs/go-ipld-cbor
v0.0.3
github.com/ipfs/go-ipld-format
v0.0.2
github.com/ipfs/go-log
v0.0.1
github.com/ipfs/go-merkledag
v0.2.3
github.com/ipfs/go-log
v1.0.4
github.com/ipfs/go-verifcid
v0.0.1
github.com/libp2p/go-libp2p-core
v0.2.2
github.com/libp2p/go-libp2p-testing
v0.1.0
github.com/multiformats/go-multihash
v0.0.8
github.com/ipld/go-codec-dagpb
v1.2.0
github.com/ipld/go-ipld-prime
v0.9.0
github.com/libp2p/go-libp2p-core
v0.8.5
github.com/libp2p/go-libp2p-testing
v0.4.0
github.com/multiformats/go-multihash
v0.0.15
)
go.sum
View file @
7463091a
This diff is collapsed.
Click to expand it.
simple/reprovide.go
View file @
7463091a
...
...
@@ -9,11 +9,11 @@ import (
"github.com/cenkalti/backoff"
"github.com/ipfs/go-cid"
"github.com/ipfs/go-cidutil"
"github.com/ipfs/go-fetcher"
blocks
"github.com/ipfs/go-ipfs-blockstore"
ipld
"github.com/ipfs/go-ipld-format"
logging
"github.com/ipfs/go-log"
"github.com/ipfs/go-merkledag"
"github.com/ipfs/go-verifcid"
cidlink
"github.com/ipld/go-ipld-prime/linking/cid"
"github.com/libp2p/go-libp2p-core/routing"
)
...
...
@@ -184,9 +184,9 @@ type Pinner interface {
}
// NewPinnedProvider returns provider supplying pinned keys
func
NewPinnedProvider
(
onlyRoots
bool
,
pinning
Pinner
,
dag
ipld
.
DAGService
)
KeyChanFunc
{
func
NewPinnedProvider
(
onlyRoots
bool
,
pinning
Pinner
,
fetchConfig
fetcher
.
FetcherConfig
)
KeyChanFunc
{
return
func
(
ctx
context
.
Context
)
(
<-
chan
cid
.
Cid
,
error
)
{
set
,
err
:=
pinSet
(
ctx
,
pinning
,
da
g
,
onlyRoots
)
set
,
err
:=
pinSet
(
ctx
,
pinning
,
fetchConfi
g
,
onlyRoots
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -208,7 +208,7 @@ func NewPinnedProvider(onlyRoots bool, pinning Pinner, dag ipld.DAGService) KeyC
}
}
func
pinSet
(
ctx
context
.
Context
,
pinning
Pinner
,
dag
ipld
.
DAGService
,
onlyRoots
bool
)
(
*
cidutil
.
StreamingSet
,
error
)
{
func
pinSet
(
ctx
context
.
Context
,
pinning
Pinner
,
fetchConfig
fetcher
.
FetcherConfig
,
onlyRoots
bool
)
(
*
cidutil
.
StreamingSet
,
error
)
{
set
:=
cidutil
.
NewStreamingSet
()
go
func
()
{
...
...
@@ -230,11 +230,18 @@ func pinSet(ctx context.Context, pinning Pinner, dag ipld.DAGService, onlyRoots
logR
.
Errorf
(
"reprovide indirect pins: %s"
,
err
)
return
}
session
:=
fetchConfig
.
NewSession
(
ctx
)
for
_
,
key
:=
range
rkeys
{
if
onlyRoots
{
set
.
Visitor
(
ctx
)(
key
)
}
else
{
err
:=
merkledag
.
Walk
(
ctx
,
merkledag
.
GetLinksWithDAG
(
dag
),
key
,
set
.
Visitor
(
ctx
))
set
.
Visitor
(
ctx
)(
key
)
if
!
onlyRoots
{
err
:=
fetcher
.
BlockAll
(
ctx
,
session
,
cidlink
.
Link
{
key
},
func
(
res
fetcher
.
FetchResult
)
error
{
clink
,
ok
:=
res
.
LastBlockLink
.
(
cidlink
.
Link
)
if
ok
{
set
.
Visitor
(
ctx
)(
clink
.
Cid
)
}
return
nil
})
if
err
!=
nil
{
logR
.
Errorf
(
"reprovide indirect pins: %s"
,
err
)
return
...
...
simple/reprovide_test.go
View file @
7463091a
...
...
@@ -9,11 +9,12 @@ import (
"github.com/ipfs/go-cid"
ds
"github.com/ipfs/go-datastore"
dssync
"github.com/ipfs/go-datastore/sync"
"github.com/ipfs/go-fetcher"
"github.com/ipfs/go-ipfs-blockstore"
offline
"github.com/ipfs/go-ipfs-exchange-offline"
mock
"github.com/ipfs/go-ipfs-routing/mock"
cbor
"github.com/ipfs/go-ipld-cbor"
merkledag
"github.com/ip
fs
/go-
merkledag
"
_
"github.com/ip
ld
/go-
ipld-prime/codec/dagcbor
"
peer
"github.com/libp2p/go-libp2p-core/peer"
testutil
"github.com/libp2p/go-libp2p-testing/net"
mh
"github.com/multiformats/go-multihash"
...
...
@@ -195,7 +196,7 @@ func TestReprovidePinned(t *testing.T) {
nodes
,
bstore
:=
setupDag
(
t
)
dag
:=
merkledag
.
NewDAGService
(
bsrv
.
New
(
bstore
,
offline
.
Exchange
(
bstore
)))
fetchConfig
:=
fetcher
.
NewFetcherConfig
(
bsrv
.
New
(
bstore
,
offline
.
Exchange
(
bstore
)))
for
i
:=
0
;
i
<
2
;
i
++
{
clA
,
clB
,
idA
,
_
:=
setupRouting
(
t
)
...
...
@@ -215,7 +216,7 @@ func TestReprovidePinned(t *testing.T) {
keyProvider
:=
NewPinnedProvider
(
onlyRoots
,
&
mockPinner
{
recursive
:
[]
cid
.
Cid
{
nodes
[
1
]},
direct
:
[]
cid
.
Cid
{
nodes
[
3
]},
},
da
g
)
},
fetchConfi
g
)
reprov
:=
NewReprovider
(
ctx
,
time
.
Hour
,
clA
,
keyProvider
)
err
:=
reprov
.
Reprovide
()
...
...
tavit ohanian
@tavit
mentioned in commit
46797b12
·
May 04, 2021
mentioned in commit
46797b12
mentioned in commit 46797b12263096b6acbc422169311eef194e530b
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment