Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-kad-dht
Commits
e3d7d2b5
Commit
e3d7d2b5
authored
Oct 28, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(routing) use routing.ErrNotFound
parent
be52e35e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
9 deletions
+13
-9
dht.go
dht.go
+4
-3
ext_test.go
ext_test.go
+4
-3
query.go
query.go
+2
-1
routing.go
routing.go
+3
-2
No files found.
dht.go
View file @
e3d7d2b5
...
...
@@ -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
...
...
ext_test.go
View file @
e3d7d2b5
...
...
@@ -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
:
...
...
query.go
View file @
e3d7d2b5
...
...
@@ -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
()
:
...
...
routing.go
View file @
e3d7d2b5
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment