Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
a768598c
Commit
a768598c
authored
6 years ago
by
vyzo
Browse files
Options
Download
Email Patches
Plain Diff
free standing Ping function
parent
4dc78663
master
fix/473
fix/no-custom-field
punching
v6.0.23
v6.0.22
v6.0.21
v6.0.20
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
p2p/protocol/ping/ping.go
+6
-2
p2p/protocol/ping/ping.go
with
6 additions
and
2 deletions
+6
-2
p2p/protocol/ping/ping.go
View file @
a768598c
...
...
@@ -72,7 +72,11 @@ func (p *PingService) PingHandler(s inet.Stream) {
}
func
(
ps
*
PingService
)
Ping
(
ctx
context
.
Context
,
p
peer
.
ID
)
(
<-
chan
time
.
Duration
,
error
)
{
s
,
err
:=
ps
.
Host
.
NewStream
(
ctx
,
p
,
ID
)
return
Ping
(
ctx
,
ps
.
Host
,
p
)
}
func
Ping
(
ctx
context
.
Context
,
h
host
.
Host
,
p
peer
.
ID
)
(
<-
chan
time
.
Duration
,
error
)
{
s
,
err
:=
h
.
NewStream
(
ctx
,
p
,
ID
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -92,7 +96,7 @@ func (ps *PingService) Ping(ctx context.Context, p peer.ID) (<-chan time.Duratio
return
}
ps
.
Host
.
Peerstore
()
.
RecordLatency
(
p
,
t
)
h
.
Peerstore
()
.
RecordLatency
(
p
,
t
)
select
{
case
out
<-
t
:
case
<-
ctx
.
Done
()
:
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help