提交 8f24275a 作者: Jeromy Johnson

Merge pull request #2676 from ipfs/feature/add-default-to-ping

Added Default to ping, cleaned up logic
......@@ -39,7 +39,7 @@ trip latency information.
cmds.StringArg("peer ID", true, true, "ID of peer to be pinged.").EnableStdin(),
},
Options: []cmds.Option{
cmds.IntOption("count", "n", "Number of ping messages to send."),
cmds.IntOption("count", "n", "Number of ping messages to send.").Default(10),
},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
......@@ -97,16 +97,11 @@ trip latency information.
n.Peerstore.AddAddr(peerID, addr, peer.TempAddrTTL) // temporary
}
// Set up number of pings
numPings := 10
val, found, err := req.Option("count").Int()
numPings, _, err := req.Option("count").Int()
if err != nil {
res.SetError(err, cmds.ErrNormal)
return
}
if found {
numPings = val
}
outChan := pingPeer(ctx, n, peerID, numPings)
res.SetOutput(outChan)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论