Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
7d842466
Unverified
提交
7d842466
authored
3月 24, 2018
作者:
Whyrusleeping
提交者:
GitHub
3月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4154 from ipfs/feat/lowpower-profile
Add low power init profile
上级
b1b96fc9
af9b4af5
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
70 行增加
和
5 行删除
+70
-5
daemon.go
cmd/ipfs/daemon.go
+18
-1
init.go
cmd/ipfs/init.go
+3
-0
config.md
docs/config.md
+6
-0
config.go
repo/config/config.go
+1
-0
init.go
repo/config/init.go
+10
-4
profile.go
repo/config/profile.go
+11
-0
routing.go
repo/config/routing.go
+7
-0
t0020-init.sh
test/sharness/t0020-init.sh
+14
-0
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
7d842466
...
...
@@ -45,6 +45,7 @@ const (
routingOptionDHTClientKwd
=
"dhtclient"
routingOptionDHTKwd
=
"dht"
routingOptionNoneKwd
=
"none"
routingOptionDefaultKwd
=
"default"
unencryptTransportKwd
=
"disable-transport-encryption"
unrestrictedApiAccessKwd
=
"unrestricted-api"
writableKwd
=
"writable"
...
...
@@ -150,7 +151,7 @@ Headers.
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
BoolOption
(
initOptionKwd
,
"Initialize ipfs with default settings if not already initialized"
),
cmdkit
.
StringOption
(
initProfileOptionKwd
,
"Configuration profiles to apply for --init. See ipfs init --help for more"
),
cmdkit
.
StringOption
(
routingOptionKwd
,
"Overrides the routing option"
)
.
WithDefault
(
"d
h
t"
),
cmdkit
.
StringOption
(
routingOptionKwd
,
"Overrides the routing option"
)
.
WithDefault
(
"d
efaul
t"
),
cmdkit
.
BoolOption
(
mountKwd
,
"Mounts IPFS to the filesystem"
),
cmdkit
.
BoolOption
(
writableKwd
,
"Enable writing objects (with POST, PUT and DELETE)"
),
cmdkit
.
StringOption
(
ipfsMountKwd
,
"Path to the mountpoint for IPFS (if using --mount). Defaults to config setting."
),
...
...
@@ -300,6 +301,22 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
}
routingOption
,
_
:=
req
.
Options
[
routingOptionKwd
]
.
(
string
)
if
err
!=
nil
{
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
if
routingOption
==
routingOptionDefaultKwd
{
cfg
,
err
:=
repo
.
Config
()
if
err
!=
nil
{
re
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
routingOption
=
cfg
.
Routing
.
Type
if
routingOption
==
""
{
routingOption
=
routingOptionDHTKwd
}
}
switch
routingOption
{
case
routingOptionSupernodeKwd
:
re
.
SetError
(
errors
.
New
(
"supernode routing was never fully implemented and has been removed"
),
cmdkit
.
ErrNormal
)
...
...
cmd/ipfs/init.go
浏览文件 @
7d842466
...
...
@@ -39,6 +39,9 @@ Available profiles:
running IPFS on machines with public IPv4 addresses.
'test' - Reduces external interference of IPFS daemon, this
is useful when using the daemon in test environments.
'lowpower' - Reduces daemon overhead on the system. May affect node
functionality - performance of content discovery and data fetching
may be degraded.
ipfs uses a repository in the local file system. By default, the repo is
located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
...
...
docs/config.md
浏览文件 @
7d842466
...
...
@@ -197,6 +197,12 @@ Default: `true`
-
`Interval`
A number of seconds to wait between discovery checks.
-
`Routing`
Content routing mode. Can be overridden with daemon
`--routing`
flag.
Valid modes are:
-
`dht`
(default)
-
`dhtclient`
-
`none`
## `Gateway`
Options for the HTTP gateway.
...
...
repo/config/config.go
浏览文件 @
7d842466
...
...
@@ -19,6 +19,7 @@ type Config struct {
Addresses
Addresses
// local node's addresses
Mounts
Mounts
// local node's mount points
Discovery
Discovery
// local node's discovery mechanisms
Routing
Routing
// local node's routing settings
Ipns
Ipns
// Ipns settings
Bootstrap
[]
string
// local nodes's bootstrap peer addresses
Gateway
Gateway
// local node's gateway server options
...
...
repo/config/init.go
浏览文件 @
7d842466
...
...
@@ -38,10 +38,16 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
Datastore
:
datastore
,
Bootstrap
:
BootstrapPeerStrings
(
bootstrapPeers
),
Identity
:
identity
,
Discovery
:
Discovery
{
MDNS
{
Enabled
:
true
,
Interval
:
10
,
}},
Discovery
:
Discovery
{
MDNS
:
MDNS
{
Enabled
:
true
,
Interval
:
10
,
},
},
Routing
:
Routing
{
Type
:
"dht"
,
},
// setup the node mount points.
Mounts
:
Mounts
{
...
...
repo/config/profile.go
浏览文件 @
7d842466
package
config
import
"time"
// Transformer is a function which takes configuration and applies some filter to it
type
Transformer
func
(
c
*
Config
)
error
...
...
@@ -73,6 +75,15 @@ var Profiles = map[string]Transformer{
c
.
Datastore
.
Spec
=
DefaultDatastoreConfig
()
.
Spec
return
nil
},
"lowpower"
:
func
(
c
*
Config
)
error
{
c
.
Routing
.
Type
=
"dhtclient"
c
.
Reprovider
.
Interval
=
"0"
c
.
Swarm
.
ConnMgr
.
LowWater
=
20
c
.
Swarm
.
ConnMgr
.
HighWater
=
40
c
.
Swarm
.
ConnMgr
.
GracePeriod
=
time
.
Minute
.
String
()
return
nil
},
}
func
appendSingle
(
a
[]
string
,
b
[]
string
)
[]
string
{
...
...
repo/config/routing.go
0 → 100644
浏览文件 @
7d842466
package
config
// Routing defines configuration options for libp2p routing
type
Routing
struct
{
// Type sets default daemon routing mode.
Type
string
}
test/sharness/t0020-init.sh
浏览文件 @
7d842466
...
...
@@ -167,6 +167,20 @@ test_expect_success "clean up ipfs dir" '
rm -rf "$IPFS_PATH"
'
test_expect_success
"'ipfs init --profile=lowpower' succeeds"
'
BITS="1024" &&
ipfs init --bits="$BITS" --profile=lowpower
'
test_expect_success
"'ipfs config Discovery.Routing' looks good"
'
ipfs config Routing.Type > actual_config &&
test $(cat actual_config) = "dhtclient"
'
test_expect_success
"clean up ipfs dir"
'
rm -rf "$IPFS_PATH"
'
test_init_ipfs
test_launch_ipfs_daemon
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论