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
44c9bb80
Commit
44c9bb80
authored
8 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 'pubsub peers' to list topics
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
parent
c40b3540
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
6 deletions
+49
-6
core/commands/pubsub.go
core/commands/pubsub.go
+47
-4
package.json
package.json
+2
-2
No files found.
core/commands/pubsub.go
View file @
44c9bb80
...
...
@@ -13,7 +13,7 @@ import (
cmds
"github.com/ipfs/go-ipfs/commands"
core
"github.com/ipfs/go-ipfs/core"
floodsub
"gx/ipfs/Qm
XzEtq2W7rGCF9RYXL79zQvLsKZxAmT9QFtEC5FYfQYc5
/floodsub"
floodsub
"gx/ipfs/Qm
Z3zAKL7KkPdnd5dWrkiEgC2H22kaa7QBiYSAhM2xQhb4
/floodsub"
u
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
key
"gx/ipfs/Qmce4Y4zg3sYr7xKM5UueS67vhNni6EeWgCRnb7MbLJMew/go-key"
pstore
"gx/ipfs/QmdMfSLMDBDYhtc4oF3NYGCZr5dy4wQb6Ji26N4D4mdxa2/go-libp2p-peerstore"
...
...
@@ -34,9 +34,10 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
`
,
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
"pub"
:
PubsubPubCmd
,
"sub"
:
PubsubSubCmd
,
"ls"
:
PubsubLsCmd
,
"pub"
:
PubsubPubCmd
,
"sub"
:
PubsubSubCmd
,
"ls"
:
PubsubLsCmd
,
"peers"
:
PubsubPeersCmd
,
},
}
...
...
@@ -261,3 +262,45 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
cmds
.
Text
:
stringListMarshaler
,
},
}
var
PubsubPeersCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"List all peers we are currently pubsubbing with."
,
ShortDescription
:
`
ipfs pubsub peers lists out the pubsub peers you are currently connected to.
This is an experimental feature. It is not intended in its current state
to be used in a production environment.
To use, the daemon must be run with '--enable-pubsub-experiment'.
`
,
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
// Must be online!
if
!
n
.
OnlineMode
()
{
res
.
SetError
(
errNotOnline
,
cmds
.
ErrClient
)
return
}
if
n
.
Floodsub
==
nil
{
res
.
SetError
(
fmt
.
Errorf
(
"experimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use."
),
cmds
.
ErrNormal
)
return
}
var
out
[]
string
for
_
,
p
:=
range
n
.
Floodsub
.
ListPeers
()
{
out
=
append
(
out
,
p
.
Pretty
())
}
res
.
SetOutput
(
&
stringList
{
out
})
},
Type
:
stringList
{},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
stringListMarshaler
,
},
}
This diff is collapsed.
Click to expand it.
package.json
View file @
44c9bb80
...
...
@@ -266,9 +266,9 @@
},
{
"author"
:
"whyrusleeping"
,
"hash"
:
"Qm
XzEtq2W7rGCF9RYXL79zQvLsKZxAmT9QFtEC5FYfQYc5
"
,
"hash"
:
"Qm
Z3zAKL7KkPdnd5dWrkiEgC2H22kaa7QBiYSAhM2xQhb4
"
,
"name"
:
"floodsub"
,
"version"
:
"0.
5
.0"
"version"
:
"0.
6
.0"
}
],
"gxVersion"
:
"0.4.0"
,
...
...
This diff is collapsed.
Click to expand it.
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