diff --git a/provider/offline.go b/provider/offline.go index 5511364ed..030a70ab1 100644 --- a/provider/offline.go +++ b/provider/offline.go @@ -2,6 +2,7 @@ package provider import ( "context" + "github.com/ipfs/go-cid" ) diff --git a/provider/provider.go b/provider/provider.go index 7dec4c172..3b9c6ba3e 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -2,6 +2,7 @@ package provider import ( "context" + "github.com/ipfs/go-cid" ) diff --git a/provider/queue/queue.go b/provider/queue/queue.go index 753d66c63..d2ba30a79 100644 --- a/provider/queue/queue.go +++ b/provider/queue/queue.go @@ -3,8 +3,6 @@ package queue import ( "context" "fmt" - "time" - cid "github.com/ipfs/go-cid" datastore "github.com/ipfs/go-datastore" namespace "github.com/ipfs/go-datastore/namespace" @@ -29,6 +27,8 @@ type Queue struct { enqueue chan cid.Cid close context.CancelFunc closed chan struct{} + + counter int } // NewQueue creates a queue for cids @@ -117,7 +117,8 @@ func (q *Queue) work() { select { case toQueue := <-q.enqueue: - keyPath := fmt.Sprintf("%d/%s", time.Now().UnixNano(), c.String()) + keyPath := fmt.Sprintf("%063d/%s", q.counter, c.String()) + q.counter++ nextKey := datastore.NewKey(keyPath) if err := q.ds.Put(q.ctx, nextKey, toQueue.Bytes()); err != nil { diff --git a/provider/simple/reprovide_test.go b/provider/simple/reprovide_test.go index 4d5563b0d..e29d6e408 100644 --- a/provider/simple/reprovide_test.go +++ b/provider/simple/reprovide_test.go @@ -127,6 +127,14 @@ func testReprovide(t *testing.T, trigger func(r *Reprovider, ctx context.Context maxProvs := 100 for _, c := range nodes { + // We provide raw cids because of the multihash keying + // FIXME(@Jorropo): I think this change should be done in the DHT layer, probably an issue with our routing mock. + b := c.Bytes() + b[1] = 0x55 // rewrite the cid to raw + _, c, err := cid.CidFromBytes(b) + if err != nil { + t.Fatal(err) + } provChan := clB.FindProvidersAsync(ctx, c, maxProvs) for p := range provChan { providers = append(providers, p) diff --git a/provider/system.go b/provider/system.go index b3e17ee40..9fc3e8879 100644 --- a/provider/system.go +++ b/provider/system.go @@ -2,6 +2,7 @@ package provider import ( "context" + "github.com/ipfs/go-cid" )