@cryptotaxi247 / kubo / commits / 254620d3a

Added Default to ping, cleaned up logic

Part of #2484 License: MIT Signed-off-by: Richard Littauer <richard.littauer@gmail.com>

Richard Littauer committed May 12, 2016 at 11:46 UTC 254620d3a2e266128b16623d633a5c3a56b4edda
1 file changed +2 -7
core/commands/ping.go
+2 -7
@@ -39,7 +39,7 @@ trip latency information.
39 cmds.StringArg("peer ID", true, true, "ID of peer to be pinged.").EnableStdin(),
40 },
41 Options: []cmds.Option{
42 - cmds.IntOption("count", "n", "Number of ping messages to send."),
42 + cmds.IntOption("count", "n", "Number of ping messages to send.").Default(10),
43 },
44 Marshalers: cmds.MarshalerMap{
45 cmds.Text: func(res cmds.Response) (io.Reader, error) {
@@ -97,16 +97,11 @@ trip latency information.
97 n.Peerstore.AddAddr(peerID, addr, peer.TempAddrTTL) // temporary
98 }
99
100 - // Set up number of pings
101 - numPings := 10
102 - val, found, err := req.Option("count").Int()
100 + numPings, _, err := req.Option("count").Int()
101 if err != nil {
102 res.SetError(err, cmds.ErrNormal)
103 return
104 }
107 - if found {
108 - numPings = val
109 - }
105
106 outChan := pingPeer(ctx, n, peerID, numPings)
107 res.SetOutput(outChan)