Commit a6ec12a1 authored by Jeromy's avatar Jeromy

selected changes from CR

parent a7650b25
......@@ -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
}
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment