Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
c6f93380
提交
c6f93380
authored
10月 11, 2015
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix random bitswap hangs
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
上级
4ace45d9
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
92 行增加
和
3 行删除
+92
-3
wantmanager.go
exchange/bitswap/wantmanager.go
+11
-3
t0130-multinode.sh
test/sharness/t0130-multinode.sh
+81
-0
没有找到文件。
exchange/bitswap/wantmanager.go
浏览文件 @
c6f93380
...
...
@@ -56,6 +56,8 @@ type msgQueue struct {
out
bsmsg
.
BitSwapMessage
network
bsnet
.
BitSwapNetwork
refcnt
int
work
chan
struct
{}
done
chan
struct
{}
}
...
...
@@ -101,13 +103,13 @@ func (pm *WantManager) SendBlock(ctx context.Context, env *engine.Envelope) {
}
func
(
pm
*
WantManager
)
startPeerHandler
(
p
peer
.
ID
)
*
msgQueue
{
_
,
ok
:=
pm
.
peers
[
p
]
mq
,
ok
:=
pm
.
peers
[
p
]
if
ok
{
// TODO: log an error?
mq
.
refcnt
++
return
nil
}
mq
:
=
pm
.
newMsgQueue
(
p
)
mq
=
pm
.
newMsgQueue
(
p
)
// new peer, we will want to give them our full wantlist
fullwantlist
:=
bsmsg
.
New
(
true
)
...
...
@@ -129,6 +131,11 @@ func (pm *WantManager) stopPeerHandler(p peer.ID) {
return
}
pq
.
refcnt
--
if
pq
.
refcnt
>
0
{
return
}
close
(
pq
.
done
)
delete
(
pm
.
peers
,
p
)
}
...
...
@@ -247,6 +254,7 @@ func (wm *WantManager) newMsgQueue(p peer.ID) *msgQueue {
mq
.
work
=
make
(
chan
struct
{},
1
)
mq
.
network
=
wm
.
network
mq
.
p
=
p
mq
.
refcnt
=
1
return
mq
}
...
...
test/sharness/t0130-multinode.sh
0 → 100755
浏览文件 @
c6f93380
#!/bin/sh
#
# Copyright (c) 2015 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test multiple ipfs nodes"
.
lib/test-lib.sh
export
IPTB_ROOT
=
"
`
pwd
`
/.iptb"
ipfsi
()
{
dir
=
"
$1
"
shift
IPFS_PATH
=
"
$IPTB_ROOT
/
$dir
"
ipfs
$@
}
check_has_connection
()
{
node
=
$1
ipfsi
$node
swarm peers |
grep
ipfs
>
/dev/null
}
startup_cluster
()
{
test_expect_success
"start up nodes"
'
iptb start
'
test_expect_success
"connect nodes to eachother"
'
iptb connect [1-4] 0
'
test_expect_success
"nodes are connected"
'
check_has_connection 0 &&
check_has_connection 1 &&
check_has_connection 2 &&
check_has_connection 3 &&
check_has_connection 4
'
}
check_file_fetch
()
{
node
=
$1
fhash
=
$2
fname
=
$3
test_expect_success
"can fetch file"
'
ipfsi $node cat $fhash > fetch_out
'
test_expect_success
"file looks good"
'
test_cmp $fname fetch_out
'
}
run_basic_test
()
{
startup_cluster
test_expect_success
"add a file on node1"
'
random 1000000 > filea &&
FILEA_HASH=$(ipfsi 1 add -q filea)
'
check_file_fetch 4
$FILEA_HASH
filea
check_file_fetch 3
$FILEA_HASH
filea
check_file_fetch 2
$FILEA_HASH
filea
check_file_fetch 1
$FILEA_HASH
filea
check_file_fetch 0
$FILEA_HASH
filea
test_expect_success
"shut down nodes"
'
iptb stop
'
}
test_expect_success
"set up tcp testbed"
'
iptb init -n 5 -p 0 -f --bootstrap=none
'
run_basic_test
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论