Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
429decc9
提交
429decc9
authored
10月 01, 2016
作者:
Jeromy Johnson
提交者:
GitHub
10月 01, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3269 from ipfs/feat/dht-client-mode
add experimental dht client mode flag
上级
e1c40dfa
a7762da3
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
99 行增加
和
3 行删除
+99
-3
daemon.go
cmd/ipfs/daemon.go
+16
-1
core.go
core/core.go
+8
-0
package.json
package.json
+2
-2
t0131-multinode-client-routing.sh
test/sharness/t0131-multinode-client-routing.sh
+73
-0
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
429decc9
...
...
@@ -43,6 +43,7 @@ const (
offlineKwd
=
"offline"
routingOptionKwd
=
"routing"
routingOptionSupernodeKwd
=
"supernode"
routingOptionDHTClientKwd
=
"dhtclient"
unencryptTransportKwd
=
"disable-transport-encryption"
unrestrictedApiAccessKwd
=
"unrestricted-api"
writableKwd
=
"writable"
...
...
@@ -120,6 +121,17 @@ environment variable:
export IPFS_PATH=/path/to/ipfsrepo
Routing
IPFS by default will use a DHT for content routing. There is a highly
experimental alternative that operates the DHT in a 'client only' mode that can
be enabled by running the daemon as:
ipfs daemon --routing=dhtclient
This will later be transitioned into a config option once it gets out of the
'experimental' stage.
DEPRECATION NOTICE
Previously, IPFS used an environment variable as seen below:
...
...
@@ -286,7 +298,8 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
if
routingOption
==
routingOptionSupernodeKwd
{
switch
routingOption
{
case
routingOptionSupernodeKwd
:
servers
,
err
:=
cfg
.
SupernodeRouting
.
ServerIPFSAddrs
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
...
...
@@ -302,6 +315,8 @@ func daemonFunc(req cmds.Request, res cmds.Response) {
}
ncfg
.
Routing
=
corerouting
.
SupernodeClient
(
infos
...
)
case
routingOptionDHTClientKwd
:
ncfg
.
Routing
=
core
.
DHTClientOption
}
node
,
err
:=
core
.
NewNode
(
req
.
Context
(),
ncfg
)
...
...
core/core.go
浏览文件 @
429decc9
...
...
@@ -646,9 +646,17 @@ func constructDHTRouting(ctx context.Context, host p2phost.Host, dstore repo.Dat
return
dhtRouting
,
nil
}
func
constructClientDHTRouting
(
ctx
context
.
Context
,
host
p2phost
.
Host
,
dstore
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
dhtRouting
:=
dht
.
NewDHTClient
(
ctx
,
host
,
dstore
)
dhtRouting
.
Validator
[
IpnsValidatorTag
]
=
namesys
.
IpnsRecordValidator
dhtRouting
.
Selector
[
IpnsValidatorTag
]
=
namesys
.
IpnsSelectorFunc
return
dhtRouting
,
nil
}
type
RoutingOption
func
(
context
.
Context
,
p2phost
.
Host
,
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
type
DiscoveryOption
func
(
context
.
Context
,
p2phost
.
Host
)
(
discovery
.
Service
,
error
)
var
DHTOption
RoutingOption
=
constructDHTRouting
var
DHTClientOption
RoutingOption
=
constructClientDHTRouting
var
NilRouterOption
RoutingOption
=
nilrouting
.
ConstructNilRouting
package.json
浏览文件 @
429decc9
...
...
@@ -52,9 +52,9 @@
"version"
:
"0.1.0"
},
{
"hash"
:
"Qm
a1FrGRasghpuETfCtsKdFtXKQffpNnakv3wG3QaMwCVi
"
,
"hash"
:
"Qm
PxBCkNrrtx5cmg62TxiE3JUM2zTqTpps3diQ9PgNrcgn
"
,
"name"
:
"iptb"
,
"version"
:
"1.
0
.0"
"version"
:
"1.
1
.0"
},
{
"hash"
:
"QmYf7ng2hG5XBtJA3tN34DQ2GUN5HNksEw1rLDkmr6vGku"
,
...
...
test/sharness/t0131-multinode-client-routing.sh
0 → 100755
浏览文件 @
429decc9
#!/bin/sh
#
# Copyright (c) 2015 Jeromy Johnson
# MIT Licensed; see the LICENSE file in this repository.
#
test_description
=
"Test client mode dht"
.
lib/test-lib.sh
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_single_file_test
()
{
test_expect_success
"add a file on node1"
'
random 1000000 > filea &&
FILEA_HASH=$(ipfsi 1 add -q filea)
'
check_file_fetch 9
$FILEA_HASH
filea
check_file_fetch 8
$FILEA_HASH
filea
check_file_fetch 7
$FILEA_HASH
filea
check_file_fetch 6
$FILEA_HASH
filea
check_file_fetch 5
$FILEA_HASH
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
}
NNODES
=
10
test_expect_success
"set up testbed"
'
iptb init -n $NNODES -p 0 -f --bootstrap=none
'
test_expect_success
"start up nodes"
'
iptb start [0-7] &&
iptb start [8-9] --args="--routing=dhtclient"
'
test_expect_success
"connect up nodes"
'
iptb connect [1-9] 0
'
test_expect_success
"add a file on a node in client mode"
'
random 1000000 > filea &&
FILE_HASH=$(ipfsi 8 add -q filea)
'
test_expect_success
"retrieve that file on a client mode node"
'
check_file_fetch 9 $FILE_HASH filea
'
run_single_file_test
test_expect_success
"shut down nodes"
'
iptb stop
'
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论