Commit e3d7d2b5 authored by Brian Tiger Chow's avatar Brian Tiger Chow

refactor(routing) use routing.ErrNotFound

parent be52e35e
......@@ -11,6 +11,7 @@ import (
inet "github.com/jbenet/go-ipfs/net"
msg "github.com/jbenet/go-ipfs/net/message"
peer "github.com/jbenet/go-ipfs/peer"
routing "github.com/jbenet/go-ipfs/routing"
pb "github.com/jbenet/go-ipfs/routing/dht/pb"
kb "github.com/jbenet/go-ipfs/routing/kbucket"
u "github.com/jbenet/go-ipfs/util"
......@@ -288,8 +289,8 @@ func (dht *IpfsDHT) getValueOrPeers(ctx context.Context, p peer.Peer,
return nil, peers, nil
}
log.Warning("getValueOrPeers: u.ErrNotFound")
return nil, nil, u.ErrNotFound
log.Warning("getValueOrPeers: routing.ErrNotFound")
return nil, nil, routing.ErrNotFound
}
// getValueSingle simply performs the get value RPC with the given parameters
......@@ -326,7 +327,7 @@ func (dht *IpfsDHT) getFromPeerList(ctx context.Context, key u.Key,
return value, nil
}
}
return nil, u.ErrNotFound
return nil, routing.ErrNotFound
}
// getLocal attempts to retrieve the value from the datastore
......
......@@ -12,6 +12,7 @@ import (
msg "github.com/jbenet/go-ipfs/net/message"
mux "github.com/jbenet/go-ipfs/net/mux"
peer "github.com/jbenet/go-ipfs/peer"
"github.com/jbenet/go-ipfs/routing"
pb "github.com/jbenet/go-ipfs/routing/dht/pb"
u "github.com/jbenet/go-ipfs/util"
......@@ -145,7 +146,7 @@ func TestGetFailures(t *testing.T) {
ctx2, _ := context.WithTimeout(context.Background(), time.Second)
_, err = d.GetValue(ctx2, u.Key("test"))
if err != nil {
if err != u.ErrNotFound {
if err != routing.ErrNotFound {
t.Fatalf("Expected ErrNotFound, got: %s", err)
}
} else {
......@@ -247,7 +248,7 @@ func TestNotFound(t *testing.T) {
log.Debug("get value got %v", v)
if err != nil {
switch err {
case u.ErrNotFound:
case routing.ErrNotFound:
//Success!
return
case u.ErrTimeout:
......@@ -311,7 +312,7 @@ func TestLessThanKResponses(t *testing.T) {
_, err := d.GetValue(ctx, u.Key("hello"))
if err != nil {
switch err {
case u.ErrNotFound:
case routing.ErrNotFound:
//Success!
return
case u.ErrTimeout:
......
......@@ -6,6 +6,7 @@ import (
inet "github.com/jbenet/go-ipfs/net"
peer "github.com/jbenet/go-ipfs/peer"
queue "github.com/jbenet/go-ipfs/peer/queue"
"github.com/jbenet/go-ipfs/routing"
kb "github.com/jbenet/go-ipfs/routing/kbucket"
u "github.com/jbenet/go-ipfs/util"
todoctr "github.com/jbenet/go-ipfs/util/todocounter"
......@@ -128,7 +129,7 @@ func (r *dhtQueryRunner) Run(peers []peer.Peer) (*dhtQueryResult, error) {
// so workers are working.
// wait until they're done.
err := u.ErrNotFound
err := routing.ErrNotFound
select {
case <-r.peersRemaining.Done():
......
......@@ -6,6 +6,7 @@ import (
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
peer "github.com/jbenet/go-ipfs/peer"
"github.com/jbenet/go-ipfs/routing"
pb "github.com/jbenet/go-ipfs/routing/dht/pb"
kb "github.com/jbenet/go-ipfs/routing/kbucket"
u "github.com/jbenet/go-ipfs/util"
......@@ -89,7 +90,7 @@ func (dht *IpfsDHT) GetValue(ctx context.Context, key u.Key) ([]byte, error) {
log.Debugf("GetValue %v %v", key, result.value)
if result.value == nil {
return nil, u.ErrNotFound
return nil, routing.ErrNotFound
}
return result.value, nil
......@@ -248,7 +249,7 @@ func (dht *IpfsDHT) FindPeer(ctx context.Context, id peer.ID) (peer.Peer, error)
log.Debug("FindPeer %v %v", id, result.success)
if result.peer == nil {
return nil, u.ErrNotFound
return nil, routing.ErrNotFound
}
return result.peer, 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