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
1586f38d
Unverified
Commit
1586f38d
authored
Nov 18, 2019
by
Steven Allen
Committed by
GitHub
Nov 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16 from MichaelMure/pinner-ctx-err
adapt to go-ipfs Pinner interface changes with context and error
parents
a51bdf9d
f2597dc7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
simple/reprovide.go
simple/reprovide.go
+14
-4
simple/reprovide_test.go
simple/reprovide_test.go
+4
-4
No files found.
simple/reprovide.go
View file @
1586f38d
...
...
@@ -171,8 +171,8 @@ func NewBlockstoreProvider(bstore blocks.Blockstore) KeyChanFunc {
// Pinner interface defines how the simple.Reprovider wants to interact
// with a Pinning service
type
Pinner
interface
{
DirectKeys
()
[]
cid
.
Cid
RecursiveKeys
()
[]
cid
.
Cid
DirectKeys
(
ctx
context
.
Context
)
(
[]
cid
.
Cid
,
error
)
RecursiveKeys
(
ctx
context
.
Context
)
(
[]
cid
.
Cid
,
error
)
}
// NewPinnedProvider returns provider supplying pinned keys
...
...
@@ -208,11 +208,21 @@ func pinSet(ctx context.Context, pinning Pinner, dag ipld.DAGService, onlyRoots
defer
cancel
()
defer
close
(
set
.
New
)
for
_
,
key
:=
range
pinning
.
DirectKeys
()
{
dkeys
,
err
:=
pinning
.
DirectKeys
(
ctx
)
if
err
!=
nil
{
logR
.
Errorf
(
"reprovide direct pins: %s"
,
err
)
return
}
for
_
,
key
:=
range
dkeys
{
set
.
Visitor
(
ctx
)(
key
)
}
for
_
,
key
:=
range
pinning
.
RecursiveKeys
()
{
rkeys
,
err
:=
pinning
.
RecursiveKeys
(
ctx
)
if
err
!=
nil
{
logR
.
Errorf
(
"reprovide indirect pins: %s"
,
err
)
return
}
for
_
,
key
:=
range
rkeys
{
if
onlyRoots
{
set
.
Visitor
(
ctx
)(
key
)
}
else
{
...
...
simple/reprovide_test.go
View file @
1586f38d
...
...
@@ -100,12 +100,12 @@ type mockPinner struct {
direct
[]
cid
.
Cid
}
func
(
mp
*
mockPinner
)
DirectKeys
()
[]
cid
.
Cid
{
return
mp
.
direct
func
(
mp
*
mockPinner
)
DirectKeys
(
ctx
context
.
Context
)
(
[]
cid
.
Cid
,
error
)
{
return
mp
.
direct
,
nil
}
func
(
mp
*
mockPinner
)
RecursiveKeys
()
[]
cid
.
Cid
{
return
mp
.
recursive
func
(
mp
*
mockPinner
)
RecursiveKeys
(
ctx
context
.
Context
)
(
[]
cid
.
Cid
,
error
)
{
return
mp
.
recursive
,
nil
}
func
TestReprovidePinned
(
t
*
testing
.
T
)
{
...
...
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