@cryptotaxi247 / kubo / commits / 44c9bb803

add 'pubsub peers' to list topics

License: MIT Signed-off-by: Jeromy <why@ipfs.io>

Jeromy committed Sep 14, 2016 at 18:42 UTC 44c9bb803fe55c3a2ccfc19804f2bab53a8b1154
2 files changed +49 -6
core/commands/pubsub.go
+47 -4
@@ -13,7 +13,7 @@ import (
13 cmds "github.com/ipfs/go-ipfs/commands"
14 core "github.com/ipfs/go-ipfs/core"
15
16 - floodsub "gx/ipfs/QmXzEtq2W7rGCF9RYXL79zQvLsKZxAmT9QFtEC5FYfQYc5/floodsub"
16 + floodsub "gx/ipfs/QmZ3zAKL7KkPdnd5dWrkiEgC2H22kaa7QBiYSAhM2xQhb4/floodsub"
17 u "gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
18 key "gx/ipfs/Qmce4Y4zg3sYr7xKM5UueS67vhNni6EeWgCRnb7MbLJMew/go-key"
19 pstore "gx/ipfs/QmdMfSLMDBDYhtc4oF3NYGCZr5dy4wQb6Ji26N4D4mdxa2/go-libp2p-peerstore"
@@ -34,9 +34,10 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
34 `,
35 },
36 Subcommands: map[string]*cmds.Command{
37 - "pub": PubsubPubCmd,
38 - "sub": PubsubSubCmd,
39 - "ls": PubsubLsCmd,
37 + "pub": PubsubPubCmd,
38 + "sub": PubsubSubCmd,
39 + "ls": PubsubLsCmd,
40 + "peers": PubsubPeersCmd,
41 },
42 }
43
@@ -261,3 +262,45 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
262 cmds.Text: stringListMarshaler,
263 },
264 }
265 +
266 +var PubsubPeersCmd = &cmds.Command{
267 + Helptext: cmds.HelpText{
268 + Tagline: "List all peers we are currently pubsubbing with.",
269 + ShortDescription: `
270 +ipfs pubsub peers lists out the pubsub peers you are currently connected to.
271 +
272 +This is an experimental feature. It is not intended in its current state
273 +to be used in a production environment.
274 +
275 +To use, the daemon must be run with '--enable-pubsub-experiment'.
276 +`,
277 + },
278 + Run: func(req cmds.Request, res cmds.Response) {
279 + n, err := req.InvocContext().GetNode()
280 + if err != nil {
281 + res.SetError(err, cmds.ErrNormal)
282 + return
283 + }
284 +
285 + // Must be online!
286 + if !n.OnlineMode() {
287 + res.SetError(errNotOnline, cmds.ErrClient)
288 + return
289 + }
290 +
291 + if n.Floodsub == nil {
292 + res.SetError(fmt.Errorf("experimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use."), cmds.ErrNormal)
293 + return
294 + }
295 +
296 + var out []string
297 + for _, p := range n.Floodsub.ListPeers() {
298 + out = append(out, p.Pretty())
299 + }
300 + res.SetOutput(&stringList{out})
301 + },
302 + Type: stringList{},
303 + Marshalers: cmds.MarshalerMap{
304 + cmds.Text: stringListMarshaler,
305 + },
306 +}
package.json
+2 -2
@@ -266,9 +266,9 @@
266 },
267 {
268 "author": "whyrusleeping",
269 - "hash": "QmXzEtq2W7rGCF9RYXL79zQvLsKZxAmT9QFtEC5FYfQYc5",
269 + "hash": "QmZ3zAKL7KkPdnd5dWrkiEgC2H22kaa7QBiYSAhM2xQhb4",
270 "name": "floodsub",
271 - "version": "0.5.0"
271 + "version": "0.6.0"
272 }
273 ],
274 "gxVersion": "0.4.0",