Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
96648f27
提交
96648f27
authored
2月 15, 2018
作者:
vyzo
提交者:
Łukasz Magiera
2月 05, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
namecache: post-rebase updates
License: MIT Signed-off-by:
vyzo
<
vyzo@hackzen.org
>
上级
36a1eb6f
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
29 行增加
和
27 行删除
+29
-27
daemon.go
cmd/ipfs/daemon.go
+1
-1
builder.go
core/builder.go
+5
-1
follow.go
core/commands/follow.go
+3
-5
namecache.go
namecache/namecache.go
+20
-20
没有找到文件。
cmd/ipfs/daemon.go
浏览文件 @
96648f27
...
...
@@ -289,7 +289,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
ipnsps
,
_
:=
req
.
Options
[
enableIPNSPubSubKwd
]
.
(
bool
)
pubsub
,
_
:=
req
.
Options
[
enablePubSubKwd
]
.
(
bool
)
mplex
,
_
:=
req
.
Options
[
enableMultiplexKwd
]
.
(
bool
)
follow
,
_
:=
req
.
Option
(
enableFollowKwd
)
.
Bool
(
)
follow
,
_
:=
req
.
Option
s
[
enableFollowKwd
]
.
(
bool
)
// Start assembling node config
ncfg
:=
&
core
.
BuildCfg
{
...
...
core/builder.go
浏览文件 @
96648f27
...
...
@@ -256,7 +256,11 @@ func setupNode(ctx context.Context, n *IpfsNode, cfg *BuildCfg) error {
if
cfg
.
Online
{
do
:=
setupDiscoveryOption
(
rcfg
.
Discovery
)
if
err
:=
n
.
startOnlineServices
(
ctx
,
cfg
.
Routing
,
hostOption
,
do
,
cfg
.
getOpt
(
"pubsub"
),
cfg
.
getOpt
(
"ipnsps"
),
cfg
.
getOpt
(
"mplex"
),
cfg
.
getOpt
(
"follow"
));
err
!=
nil
{
pubsub
:=
cfg
.
getOpt
(
"pubsub"
)
ipnsps
:=
cfg
.
getOpt
(
"ipnsps"
)
mplex
:=
cfg
.
getOpt
(
"mplex"
)
follow
:=
cfg
.
getOpt
(
"follow"
)
if
err
:=
n
.
startOnlineServices
(
ctx
,
cfg
.
Routing
,
hostOption
,
do
,
pubsub
,
ipnsps
,
mplex
,
follow
);
err
!=
nil
{
return
err
}
}
else
{
...
...
core/commands/follow.go
浏览文件 @
96648f27
...
...
@@ -43,7 +43,7 @@ Follows an IPNS name by periodically resolving in the backround.
},
Options
:
[]
cmdkit
.
Option
{
cmdkit
.
BoolOption
(
"pin"
,
"Recursively pin the resolved pointer"
),
cmdkit
.
StringOption
(
"refresh-interval"
,
"Follow refresh interval."
),
cmdkit
.
StringOption
(
"refresh-interval"
,
"Follow refresh interval
; defaults to 1hr
."
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
...
...
@@ -66,10 +66,8 @@ Follows an IPNS name by periodically resolving in the backround.
return
}
var
refr
time
.
Duration
if
refrS
==
""
{
refr
=
nc
.
DefaultFollowInterval
}
else
{
refr
:=
nc
.
DefaultFollowInterval
if
refrS
!=
""
{
refr
,
err
=
time
.
ParseDuration
(
refrS
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
...
...
namecache/namecache.go
浏览文件 @
96648f27
...
...
@@ -29,8 +29,8 @@ var log = logging.Logger("namecache")
// NameCache represents a following cache of names
type
NameCache
interface
{
// Follow starts following name, pinning it if
pinit
is true
Follow
(
name
string
,
pinit
bool
,
followInterval
time
.
Duration
)
error
// Follow starts following name, pinning it if
dopin
is true
Follow
(
name
string
,
dopin
bool
,
followInterval
time
.
Duration
)
error
// Unofollow cancels a follow
Unfollow
(
name
string
)
error
// ListFollows returns a list of followed names
...
...
@@ -40,7 +40,7 @@ type NameCache interface {
type
nameCache
struct
{
nsys
namesys
.
NameSystem
pinning
pin
.
Pinner
dag
ipld
.
DAGService
dag
ipld
.
NodeGetter
bstore
bstore
.
GCBlockstore
ctx
context
.
Context
...
...
@@ -48,7 +48,7 @@ type nameCache struct {
mx
sync
.
Mutex
}
func
NewNameCache
(
ctx
context
.
Context
,
nsys
namesys
.
NameSystem
,
pinning
pin
.
Pinner
,
dag
ipld
.
DAGService
,
bstore
bstore
.
GCBlockstore
)
NameCache
{
func
NewNameCache
(
ctx
context
.
Context
,
nsys
namesys
.
NameSystem
,
pinning
pin
.
Pinner
,
dag
ipld
.
NodeGetter
,
bstore
bstore
.
GCBlockstore
)
NameCache
{
return
&
nameCache
{
ctx
:
ctx
,
nsys
:
nsys
,
...
...
@@ -60,8 +60,8 @@ func NewNameCache(ctx context.Context, nsys namesys.NameSystem, pinning pin.Pinn
}
// Follow spawns a goroutine that periodically resolves a name
// and (when
pinit
is true) pins it in the background
func
(
nc
*
nameCache
)
Follow
(
name
string
,
pinit
bool
,
followInterval
time
.
Duration
)
error
{
// and (when
dopin
is true) pins it in the background
func
(
nc
*
nameCache
)
Follow
(
name
string
,
dopin
bool
,
followInterval
time
.
Duration
)
error
{
nc
.
mx
.
Lock
()
defer
nc
.
mx
.
Unlock
()
...
...
@@ -74,7 +74,7 @@ func (nc *nameCache) Follow(name string, pinit bool, followInterval time.Duratio
}
ctx
,
cancel
:=
context
.
WithCancel
(
nc
.
ctx
)
go
nc
.
followName
(
ctx
,
name
,
pinit
,
followInterval
)
go
nc
.
followName
(
ctx
,
name
,
dopin
,
followInterval
)
nc
.
follows
[
name
]
=
cancel
return
nil
...
...
@@ -112,10 +112,10 @@ func (nc *nameCache) ListFollows() []string {
return
follows
}
func
(
nc
*
nameCache
)
followName
(
ctx
context
.
Context
,
name
string
,
pinit
bool
,
followInterval
time
.
Duration
)
{
func
(
nc
*
nameCache
)
followName
(
ctx
context
.
Context
,
name
string
,
dopin
bool
,
followInterval
time
.
Duration
)
{
// if cid != nil, we have created a new pin that is updated on changes and
// unpinned on cancel
c
,
err
:=
nc
.
resolveAndPin
(
ctx
,
name
,
pinit
)
c
,
err
:=
nc
.
resolveAndPin
(
ctx
,
name
,
dopin
)
if
err
!=
nil
{
log
.
Errorf
(
"Error following %s: %s"
,
name
,
err
.
Error
())
}
...
...
@@ -129,7 +129,7 @@ func (nc *nameCache) followName(ctx context.Context, name string, pinit bool, fo
if
c
!=
cid
.
Undef
{
c
,
err
=
nc
.
resolveAndUpdate
(
ctx
,
name
,
c
)
}
else
{
c
,
err
=
nc
.
resolveAndPin
(
ctx
,
name
,
pinit
)
c
,
err
=
nc
.
resolveAndPin
(
ctx
,
name
,
dopin
)
}
if
err
!=
nil
{
...
...
@@ -148,13 +148,13 @@ func (nc *nameCache) followName(ctx context.Context, name string, pinit bool, fo
}
}
func
(
nc
*
nameCache
)
resolveAndPin
(
ctx
context
.
Context
,
name
string
,
pinit
bool
)
(
cid
.
Cid
,
error
)
{
func
(
nc
*
nameCache
)
resolveAndPin
(
ctx
context
.
Context
,
name
string
,
dopin
bool
)
(
cid
.
Cid
,
error
)
{
ptr
,
err
:=
nc
.
resolve
(
ctx
,
name
)
if
err
!=
nil
{
return
cid
.
Undef
,
err
}
if
!
pinit
{
if
!
dopin
{
return
cid
.
Undef
,
nil
}
...
...
@@ -187,34 +187,34 @@ func (nc *nameCache) resolveAndPin(ctx context.Context, name string, pinit bool)
return
c
,
err
}
func
(
nc
*
nameCache
)
resolveAndUpdate
(
ctx
context
.
Context
,
name
string
,
c
cid
.
Cid
)
(
cid
.
Cid
,
error
)
{
func
(
nc
*
nameCache
)
resolveAndUpdate
(
ctx
context
.
Context
,
name
string
,
oldcid
cid
.
Cid
)
(
cid
.
Cid
,
error
)
{
ptr
,
err
:=
nc
.
resolve
(
ctx
,
name
)
if
err
!=
nil
{
return
cid
.
Undef
,
err
}
ncid
,
err
:=
pathToCid
(
ptr
)
n
ew
cid
,
err
:=
pathToCid
(
ptr
)
if
err
!=
nil
{
return
cid
.
Undef
,
err
}
if
n
cid
.
Equals
(
c
)
{
return
c
,
nil
if
n
ewcid
.
Equals
(
oldcid
)
{
return
oldcid
,
nil
}
defer
nc
.
bstore
.
PinLock
()
.
Unlock
()
log
.
Debugf
(
"Updating pin %s -> %s"
,
c
.
String
(),
n
cid
.
String
())
log
.
Debugf
(
"Updating pin %s -> %s"
,
oldcid
.
String
(),
new
cid
.
String
())
err
=
nc
.
pinning
.
Update
(
ctx
,
c
,
n
cid
,
true
)
err
=
nc
.
pinning
.
Update
(
ctx
,
oldcid
,
new
cid
,
true
)
if
err
!=
nil
{
return
c
,
err
return
oldcid
,
err
}
err
=
nc
.
pinning
.
Flush
()
return
ncid
,
err
return
n
ew
cid
,
err
}
func
(
nc
*
nameCache
)
unpin
(
cid
cid
.
Cid
)
error
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论