Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
e893fb90
提交
e893fb90
authored
12月 09, 2016
作者:
Jeromy Johnson
提交者:
GitHub
12月 09, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3484 from ipfs/fix/pubsub-peers-cmd
cmd/pubsub: fix peers command topic filtering
上级
477787c7
f104b8ae
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
30 行增加
和
9 行删除
+30
-9
pubsub.go
core/commands/pubsub.go
+13
-3
t0180-pubsub.sh
test/sharness/t0180-pubsub.sh
+17
-6
没有找到文件。
core/commands/pubsub.go
浏览文件 @
e893fb90
...
@@ -274,9 +274,11 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
...
@@ -274,9 +274,11 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
var
PubsubPeersCmd
=
&
cmds
.
Command
{
var
PubsubPeersCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"List
all
peers we are currently pubsubbing with."
,
Tagline
:
"List peers we are currently pubsubbing with."
,
ShortDescription
:
`
ShortDescription
:
`
ipfs pubsub peers lists out the pubsub peers you are currently connected to.
ipfs pubsub peers with no arguments lists out the pubsub peers you are
currently connected to. If given a topic, it will list connected
peers who are subscribed to the named topic.
This is an experimental feature. It is not intended in its current state
This is an experimental feature. It is not intended in its current state
to be used in a production environment.
to be used in a production environment.
...
@@ -284,6 +286,9 @@ to be used in a production environment.
...
@@ -284,6 +286,9 @@ to be used in a production environment.
To use, the daemon must be run with '--enable-pubsub-experiment'.
To use, the daemon must be run with '--enable-pubsub-experiment'.
`
,
`
,
},
},
Arguments
:
[]
cmds
.
Argument
{
cmds
.
StringArg
(
"topic"
,
false
,
false
,
"topic to list connected peers of"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
n
,
err
:=
req
.
InvocContext
()
.
GetNode
()
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -302,8 +307,13 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
...
@@ -302,8 +307,13 @@ To use, the daemon must be run with '--enable-pubsub-experiment'.
return
return
}
}
var
topic
string
if
len
(
req
.
Arguments
())
==
1
{
topic
=
req
.
Arguments
()[
0
]
}
var
out
[]
string
var
out
[]
string
for
_
,
p
:=
range
n
.
Floodsub
.
ListPeers
(
""
)
{
for
_
,
p
:=
range
n
.
Floodsub
.
ListPeers
(
topic
)
{
out
=
append
(
out
,
p
.
Pretty
())
out
=
append
(
out
,
p
.
Pretty
())
}
}
res
.
SetOutput
(
&
stringList
{
out
})
res
.
SetOutput
(
&
stringList
{
out
})
...
...
test/sharness/t0180-pubsub.sh
浏览文件 @
e893fb90
...
@@ -32,16 +32,27 @@ test_expect_success 'pubsub' '
...
@@ -32,16 +32,27 @@ test_expect_success 'pubsub' '
echo > wait
echo > wait
fi
fi
) &
) &
'
# wait until ipfs pubsub sub is ready to do work
test_expect_success
"wait until ipfs pubsub sub is ready to do work"
'
sleep 1 &&
sleep 1
'
# publish something
test_expect_success
"can see peer subscribed to testTopic"
'
ipfsi 1 pubsub pub testTopic "testOK" &> pubErr &&
ipfsi 1 pubsub peers testTopic > peers_out
'
# wait until `echo > wait` executed
test_expect_success
"output looks good"
'
cat wait &&
echo $PEERID_0 > peers_exp &&
test_cmp peers_exp peers_out
'
test_expect_success
"publish something"
'
ipfsi 1 pubsub pub testTopic "testOK" &> pubErr
'
test_expect_success
"wait until echo > wait executed"
'
cat wait &&
test_cmp pubErr empty &&
test_cmp pubErr empty &&
test_cmp expected actual
test_cmp expected actual
'
'
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论