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
Commits
a6ec12a1
Commit
a6ec12a1
authored
Jan 16, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
selected changes from CR
parent
a7650b25
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
exchange/reprovide/reprovide.go
exchange/reprovide/reprovide.go
+10
-6
exchange/reprovide/reprovide_test.go
exchange/reprovide/reprovide_test.go
+4
-1
No files found.
exchange/reprovide/reprovide.go
View file @
a6ec12a1
...
...
@@ -7,7 +7,8 @@ import (
blocks
"github.com/jbenet/go-ipfs/blocks/blockstore"
routing
"github.com/jbenet/go-ipfs/routing"
"github.com/jbenet/go-ipfs/util/eventlog"
debugerror
"github.com/jbenet/go-ipfs/util/debugerror"
eventlog
"github.com/jbenet/go-ipfs/util/eventlog"
)
var
log
=
eventlog
.
Logger
(
"reprovider"
)
...
...
@@ -34,22 +35,25 @@ func (rp *Reprovider) ProvideEvery(ctx context.Context, tick time.Duration) {
case
<-
ctx
.
Done
()
:
return
case
<-
after
:
rp
.
Reprovide
(
ctx
)
err
:=
rp
.
Reprovide
(
ctx
)
if
err
!=
nil
{
log
.
Error
(
err
)
}
after
=
time
.
After
(
tick
)
}
}
}
func
(
rp
*
Reprovider
)
Reprovide
(
ctx
context
.
Context
)
{
func
(
rp
*
Reprovider
)
Reprovide
(
ctx
context
.
Context
)
error
{
keychan
,
err
:=
rp
.
bstore
.
AllKeysChan
(
ctx
,
0
,
1
<<
16
)
if
err
!=
nil
{
log
.
Errorf
(
"Failed to get key chan from blockstore: %s"
,
err
)
return
return
debugerror
.
Errorf
(
"Failed to get key chan from blockstore: %s"
,
err
)
}
for
k
:=
range
keychan
{
err
:=
rp
.
rsys
.
Provide
(
ctx
,
k
)
if
err
!=
nil
{
log
.
Errorf
(
"Failed to provide key: %s, %s"
,
k
,
err
)
return
debugerror
.
Errorf
(
"Failed to provide key: %s, %s"
,
k
,
err
)
}
}
return
nil
}
exchange/reprovide/reprovide_test.go
View file @
a6ec12a1
...
...
@@ -33,7 +33,10 @@ func TestReprovide(t *testing.T) {
bstore
.
Put
(
blk
)
reprov
:=
NewReprovider
(
clA
,
bstore
)
reprov
.
Reprovide
(
ctx
)
err
:=
reprov
.
Reprovide
(
ctx
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
provs
,
err
:=
clB
.
FindProviders
(
ctx
,
blk
.
Key
())
if
err
!=
nil
{
...
...
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