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
dms3
go-dms3
Commits
584d4969
Commit
584d4969
authored
May 17, 2016
by
Chris Sasarak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated verbose swarm to not ping peers.
License: MIT Signed-off-by:
Chris Sasarak
<
chris.sasarak@gmail.com
>
parent
762aded6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
20 deletions
+3
-20
core/commands/swarm.go
core/commands/swarm.go
+3
-20
No files found.
core/commands/swarm.go
View file @
584d4969
...
...
@@ -7,7 +7,6 @@ import (
"io"
"path"
"sort"
"time"
cmds
"github.com/ipfs/go-ipfs/commands"
iaddr
"github.com/ipfs/go-ipfs/thirdparty/ipfsaddr"
...
...
@@ -16,7 +15,6 @@ import (
mafilter
"gx/ipfs/QmUaRHbB7pUwj5mS9BS4CMvBiW48MpaH2wbGxeWfFhhHxK/multiaddr-filter"
ma
"gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
context
"gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
)
type
stringList
struct
{
...
...
@@ -54,12 +52,10 @@ var swarmPeersCmd = &cmds.Command{
},
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"verbose"
,
"v"
,
`Also display latency along with peer information in the following form:
<peer address> <latency>
`
),
"Also display latency along with peer information in the following form: "
+
"<peer address> <latency>"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
timeout
:=
time
.
Duration
(
5
)
*
time
.
Second
log
.
Debug
(
"ipfs swarm peers"
)
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
...
...
@@ -76,26 +72,13 @@ var swarmPeersCmd = &cmds.Command{
verbose
,
_
,
_
:=
req
.
Option
(
"verbose"
)
.
Bool
()
conns
:=
n
.
PeerHost
.
Network
()
.
Conns
()
addrs
:=
make
([]
string
,
len
(
conns
))
pingService
:=
n
.
Ping
for
i
,
c
:=
range
conns
{
pid
:=
c
.
RemotePeer
()
addr
:=
c
.
RemoteMultiaddr
()
if
verbose
{
pContext
,
cancelFn
:=
context
.
WithTimeout
(
req
.
Context
(),
timeout
)
defer
cancelFn
()
ch
,
_
:=
pingService
.
Ping
(
pContext
,
pid
)
duration
:=
<-
ch
var
durStr
string
if
pContext
.
Err
()
!=
nil
{
durStr
=
pContext
.
Err
()
.
Error
()
}
else
{
durStr
=
duration
.
String
()
}
addrs
[
i
]
=
fmt
.
Sprintf
(
"%s/ipfs/%s %s"
,
addr
,
pid
.
Pretty
(),
durStr
)
addrs
[
i
]
=
fmt
.
Sprintf
(
"%s/ipfs/%s %s"
,
addr
,
pid
.
Pretty
(),
n
.
Peerstore
.
LatencyEWMA
(
pid
))
}
else
{
addrs
[
i
]
=
fmt
.
Sprintf
(
"%s/ipfs/%s"
,
addr
,
pid
.
Pretty
())
}
...
...
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