Commit 4f00ef1b authored by Erik Ingenito's avatar Erik Ingenito

Gofmt

License: MIT
Signed-off-by: default avatarErik Ingenito <erik@carbonfive.com>
parent e5715368
......@@ -11,7 +11,7 @@ import (
routing "github.com/libp2p/go-libp2p-routing"
)
var log = logging.Logger("provider")
var log = logging.Logger("provider")
const provideOutgoingWorkerLimit = 8
......
......@@ -6,11 +6,11 @@ import (
"testing"
"time"
blocksutil "github.com/ipfs/go-ipfs-blocksutil"
cid "github.com/ipfs/go-cid"
datastore "github.com/ipfs/go-datastore"
pstore "github.com/libp2p/go-libp2p-peerstore"
sync "github.com/ipfs/go-datastore/sync"
blocksutil "github.com/ipfs/go-ipfs-blocksutil"
pstore "github.com/libp2p/go-libp2p-peerstore"
)
var blockGenerator = blocksutil.NewBlockGenerator()
......@@ -58,13 +58,13 @@ func TestAnnouncement(t *testing.T) {
for cids.Len() > 0 {
select {
case cp := <-r.provided:
if !cids.Has(cp) {
t.Fatal("Wrong CID provided")
}
cids.Remove(cp)
case <-time.After(time.Second * 5):
t.Fatal("Timeout waiting for cids to be provided.")
case cp := <-r.provided:
if !cids.Has(cp) {
t.Fatal("Wrong CID provided")
}
cids.Remove(cp)
case <-time.After(time.Second * 5):
t.Fatal("Timeout waiting for cids to be provided.")
}
}
}
......@@ -77,4 +77,4 @@ func (r *mockRouting) Provide(ctx context.Context, cid cid.Cid, recursive bool)
// Search for peers who are able to provide a given key
func (r *mockRouting) FindProvidersAsync(ctx context.Context, cid cid.Cid, timeout int) <-chan pstore.PeerInfo {
return nil
}
\ No newline at end of file
}
......@@ -19,14 +19,11 @@ import (
type Queue struct {
// used to differentiate queues in datastore
// e.g. provider vs reprovider
name string
ctx context.Context
tail uint64
head uint64
ds datastore.Datastore // Must be threadsafe
name string
ctx context.Context
tail uint64
head uint64
ds datastore.Datastore // Must be threadsafe
dequeue chan cid.Cid
enqueue chan cid.Cid
}
......@@ -39,13 +36,13 @@ func NewQueue(ctx context.Context, name string, ds datastore.Datastore) (*Queue,
return nil, err
}
q := &Queue{
name: name,
ctx: ctx,
head: head,
tail: tail,
ds: namespaced,
dequeue: make(chan cid.Cid),
enqueue: make(chan cid.Cid),
name: name,
ctx: ctx,
head: head,
tail: tail,
ds: namespaced,
dequeue: make(chan cid.Cid),
enqueue: make(chan cid.Cid),
}
q.work()
return q, nil
......@@ -54,8 +51,8 @@ func NewQueue(ctx context.Context, name string, ds datastore.Datastore) (*Queue,
// Enqueue puts a cid in the queue
func (q *Queue) Enqueue(cid cid.Cid) {
select {
case q.enqueue <- cid:
case <-q.ctx.Done():
case q.enqueue <- cid:
case <-q.ctx.Done():
}
}
......
......@@ -22,7 +22,7 @@ func makeCids(n int) []cid.Cid {
func assertOrdered(cids []cid.Cid, q *Queue, t *testing.T) {
for _, c := range cids {
select {
case dequeued := <- q.dequeue:
case dequeued := <-q.dequeue:
if c != dequeued {
t.Fatalf("Error in ordering of CIDs retrieved from queue. Expected: %s, got: %s", c, dequeued)
}
......
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