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
f2669289
Commit
f2669289
authored
Jan 09, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address PR comments and add in more user feedback
parent
cadecd7f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
dht.go
dht.go
+3
-3
routing.go
routing.go
+5
-2
No files found.
dht.go
View file @
f2669289
...
...
@@ -103,8 +103,8 @@ func (dht *IpfsDHT) Connect(ctx context.Context, npeer peer.ID) error {
// Ping new peer to register in their routing table
// NOTE: this should be done better...
if
err
:=
dht
.
Ping
(
ctx
,
npeer
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to ping newly connected peer: %s
\n
"
,
err
)
if
_
,
err
:=
dht
.
Ping
(
ctx
,
npeer
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to ping newly connected peer: %s"
,
err
)
}
log
.
Event
(
ctx
,
"connect"
,
dht
.
self
,
npeer
)
dht
.
Update
(
ctx
,
npeer
)
...
...
@@ -329,7 +329,7 @@ func (dht *IpfsDHT) PingRoutine(t time.Duration) {
peers
:=
dht
.
routingTable
.
NearestPeers
(
kb
.
ConvertKey
(
u
.
Key
(
id
)),
5
)
for
_
,
p
:=
range
peers
{
ctx
,
_
:=
context
.
WithTimeout
(
dht
.
Context
(),
time
.
Second
*
5
)
err
:=
dht
.
Ping
(
ctx
,
p
)
_
,
err
:=
dht
.
Ping
(
ctx
,
p
)
if
err
!=
nil
{
log
.
Errorf
(
"Ping error: %s"
,
err
)
}
...
...
routing.go
View file @
f2669289
...
...
@@ -3,6 +3,7 @@ package dht
import
(
"math"
"sync"
"time"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
...
...
@@ -434,12 +435,14 @@ func (dht *IpfsDHT) FindPeersConnectedToPeer(ctx context.Context, id peer.ID) (<
}
// Ping a peer, log the time it took
func
(
dht
*
IpfsDHT
)
Ping
(
ctx
context
.
Context
,
p
peer
.
ID
)
error
{
func
(
dht
*
IpfsDHT
)
Ping
(
ctx
context
.
Context
,
p
peer
.
ID
)
(
time
.
Duration
,
error
)
{
// Thoughts: maybe this should accept an ID and do a peer lookup?
log
.
Debugf
(
"ping %s start"
,
p
)
before
:=
time
.
Now
()
pmes
:=
pb
.
NewMessage
(
pb
.
Message_PING
,
""
,
0
)
_
,
err
:=
dht
.
sendRequest
(
ctx
,
p
,
pmes
)
log
.
Debugf
(
"ping %s end (err = %s)"
,
p
,
err
)
return
err
return
time
.
Now
()
.
Sub
(
before
),
err
}
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