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
2482dc8f
Commit
2482dc8f
authored
May 18, 2016
by
Jeromy Johnson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2713 from csasarak/swarm_verbose
Added a verbose option for swarm peers.
parents
1e9e94f8
584d4969
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
core/commands/swarm.go
core/commands/swarm.go
+13
-1
No files found.
core/commands/swarm.go
View file @
2482dc8f
...
...
@@ -50,6 +50,11 @@ var swarmPeersCmd = &cmds.Command{
'ipfs swarm peers' lists the set of peers this node is connected to.
`
,
},
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"verbose"
,
"v"
,
"Also display latency along with peer information in the following form: "
+
"<peer address> <latency>"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
log
.
Debug
(
"ipfs swarm peers"
)
...
...
@@ -64,12 +69,19 @@ var swarmPeersCmd = &cmds.Command{
return
}
verbose
,
_
,
_
:=
req
.
Option
(
"verbose"
)
.
Bool
()
conns
:=
n
.
PeerHost
.
Network
()
.
Conns
()
addrs
:=
make
([]
string
,
len
(
conns
))
for
i
,
c
:=
range
conns
{
pid
:=
c
.
RemotePeer
()
addr
:=
c
.
RemoteMultiaddr
()
addrs
[
i
]
=
fmt
.
Sprintf
(
"%s/ipfs/%s"
,
addr
,
pid
.
Pretty
())
if
verbose
{
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
())
}
}
sort
.
Sort
(
sort
.
StringSlice
(
addrs
))
...
...
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