From 4796240aa9a97b054390bb68125a09a9b0c24dc3 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 15 Feb 2019 15:19:50 +1100 Subject: [PATCH 1/2] Remove redundant context --- query.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/query.go b/query.go index 9f2e44233..d43549955 100644 --- a/query.go +++ b/query.go @@ -57,15 +57,9 @@ type queryFunc func(context.Context, peer.ID) (*dhtQueryResult, error) // Run runs the query at hand. pass in a list of peers to use first. func (q *dhtQuery) Run(ctx context.Context, peers []peer.ID) (*dhtQueryResult, error) { - select { - case <-ctx.Done(): + if ctx.Err() != nil { return nil, ctx.Err() - default: } - - ctx, cancel := context.WithCancel(ctx) - defer cancel() - runner := newQueryRunner(q) return runner.Run(ctx, peers) } From e3abe4d301ce5f7ecf797cda12b0a90ade2a3d06 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Fri, 15 Feb 2019 15:20:13 +1100 Subject: [PATCH 2/2] Reformat import block --- dht_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dht_test.go b/dht_test.go index 2e5196120..0c23d0398 100644 --- a/dht_test.go +++ b/dht_test.go @@ -5,8 +5,6 @@ import ( "context" "errors" "fmt" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "math/rand" "sort" "strings" @@ -14,6 +12,9 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + opts "github.com/libp2p/go-libp2p-kad-dht/opts" pb "github.com/libp2p/go-libp2p-kad-dht/pb"