Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
74fad48e
提交
74fad48e
authored
4月 08, 2016
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean up dead code and config fields
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
上级
600c95eb
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
2 行增加
和
140 行删除
+2
-140
config.go
repo/config/config.go
+0
-1
init.go
repo/config/init.go
+2
-12
version.go
repo/config/version.go
+0
-127
没有找到文件。
repo/config/config.go
浏览文件 @
74fad48e
...
...
@@ -21,7 +21,6 @@ type Config struct {
Datastore
Datastore
// local node's storage
Addresses
Addresses
// local node's addresses
Mounts
Mounts
// local node's mount points
Version
Version
// local node's version management
Discovery
Discovery
// local node's discovery mechanisms
Ipns
Ipns
// Ipns settings
Bootstrap
[]
string
// local nodes's bootstrap peer addresses
...
...
repo/config/init.go
浏览文件 @
74fad48e
...
...
@@ -21,11 +21,6 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
return
nil
,
err
}
snr
,
err
:=
initSNRConfig
()
if
err
!=
nil
{
return
nil
,
err
}
conf
:=
&
Config
{
// setup the node's default addresses.
...
...
@@ -40,9 +35,8 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
Gateway
:
"/ip4/127.0.0.1/tcp/8080"
,
},
Bootstrap
:
BootstrapPeerStrings
(
bootstrapPeers
),
SupernodeRouting
:
*
snr
,
Identity
:
identity
,
Bootstrap
:
BootstrapPeerStrings
(
bootstrapPeers
),
Identity
:
identity
,
Discovery
:
Discovery
{
MDNS
{
Enabled
:
true
,
Interval
:
10
,
...
...
@@ -58,10 +52,6 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
ResolveCacheSize
:
128
,
},
// tracking ipfs version used to generate the init folder and adding
// update checker default setting.
Version
:
VersionDefaultValue
(),
Gateway
:
Gateway
{
RootRedirect
:
""
,
Writable
:
false
,
...
...
repo/config/version.go
浏览文件 @
74fad48e
package
config
import
(
"errors"
"strconv"
"strings"
"time"
)
// CurrentCommit is the current git commit, this is set as a ldflag in the Makefile
var
CurrentCommit
string
...
...
@@ -14,123 +7,3 @@ var CurrentCommit string
const
CurrentVersionNumber
=
"0.4.0"
const
ApiVersion
=
"/go-ipfs/"
+
CurrentVersionNumber
+
"/"
// Version regulates checking if the most recent version is run
type
Version
struct
{
// Current is the ipfs version for which config was generated
Current
string
// Check signals how to react on updates:
// - "ignore" for not checking
// - "warn" for issuing a warning and proceeding
// - "error" for exiting with an error
Check
string
// CheckDate is a timestamp for the last time API endpoint was checked for updates
CheckDate
time
.
Time
// CheckPeriod is the time duration over which the update check will not be performed
// (Note: cannot use time.Duration because marshalling with json breaks it)
CheckPeriod
string
// AutoUpdate is optional
AutoUpdate
AutoUpdateSetting
}
// supported Version.Check values
const
(
// CheckError value for Version.Check to raise error and exit if version is obsolete
CheckError
=
"error"
// CheckWarn value for Version.Check to show warning message if version is obsolete
CheckWarn
=
"warn"
// CheckIgnore value for Version.Check to not perform update check
CheckIgnore
=
"ignore"
)
// AutoUpdateSetting implements json.Unmarshaler to check values in config
type
AutoUpdateSetting
int
// AutoUpdateSetting values
const
(
AutoUpdateNever
AutoUpdateSetting
=
iota
// do not auto-update
AutoUpdatePatch
// only on new patch versions
AutoUpdateMinor
// on new minor or patch versions (Default)
AutoUpdateMajor
// on all, even Major, version changes
)
// ErrUnknownAutoUpdateSetting is returned when an unknown value is read from the config
var
ErrUnknownAutoUpdateSetting
=
errors
.
New
(
"unknown value for AutoUpdate"
)
// defaultCheckPeriod governs h
var
defaultCheckPeriod
=
time
.
Hour
*
48
// UnmarshalJSON checks the input against known strings
func
(
s
*
AutoUpdateSetting
)
UnmarshalJSON
(
in
[]
byte
)
error
{
switch
strings
.
ToLower
(
string
(
in
))
{
case
`"never"`
:
*
s
=
AutoUpdateNever
case
`"major"`
:
*
s
=
AutoUpdateMajor
case
`"minor"`
:
*
s
=
AutoUpdateMinor
case
`"patch"`
:
*
s
=
AutoUpdatePatch
default
:
*
s
=
AutoUpdateMinor
return
ErrUnknownAutoUpdateSetting
}
return
nil
}
// MarshalJSON converts the value back to JSON string
func
(
s
AutoUpdateSetting
)
MarshalJSON
()
([]
byte
,
error
)
{
return
[]
byte
(
`"`
+
s
.
String
()
+
`"`
),
nil
}
// String converts valye to human readable string
func
(
s
AutoUpdateSetting
)
String
()
string
{
switch
s
{
case
AutoUpdateNever
:
return
"never"
case
AutoUpdateMajor
:
return
"major"
case
AutoUpdateMinor
:
return
"minor"
case
AutoUpdatePatch
:
return
"patch"
default
:
return
ErrUnknownAutoUpdateSetting
.
Error
()
}
}
func
(
v
*
Version
)
checkPeriodDuration
()
time
.
Duration
{
d
,
err
:=
strconv
.
Atoi
(
v
.
CheckPeriod
)
if
err
!=
nil
{
log
.
Warning
(
"config.Version.CheckPeriod parse error. Using default."
)
return
defaultCheckPeriod
}
return
time
.
Duration
(
d
)
}
// ShouldCheckForUpdate returns if update check API endpoint is needed for this specific runtime
func
(
v
*
Version
)
ShouldCheckForUpdate
()
bool
{
period
:=
v
.
checkPeriodDuration
()
if
v
.
Check
==
CheckIgnore
||
v
.
CheckDate
.
Add
(
period
)
.
After
(
time
.
Now
())
{
return
false
}
return
true
}
// VersionDefaultValue returns the default version config value (for init).
func
VersionDefaultValue
()
Version
{
return
Version
{
Current
:
CurrentVersionNumber
,
Check
:
"error"
,
CheckPeriod
:
strconv
.
Itoa
(
int
(
defaultCheckPeriod
)),
AutoUpdate
:
AutoUpdateMinor
,
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论