Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
226a3019
Unverified
提交
226a3019
authored
11月 19, 2018
作者:
Michael Avila
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add 'providing' back to the ipfs add command
上级
31099e88
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
16 行删除
+34
-16
add.go
core/commands/add.go
+7
-1
reprovide.go
exchange/reprovide/reprovide.go
+27
-15
没有找到文件。
core/commands/add.go
浏览文件 @
226a3019
...
...
@@ -144,6 +144,11 @@ You can now check what blocks have been created by:
return
err
}
node
,
err
:=
cmdenv
.
GetNode
(
env
)
if
err
!=
nil
{
return
err
}
progress
,
_
:=
req
.
Options
[
progressOptionName
]
.
(
bool
)
trickle
,
_
:=
req
.
Options
[
trickleOptionName
]
.
(
bool
)
wrap
,
_
:=
req
.
Options
[
wrapOptionName
]
.
(
bool
)
...
...
@@ -209,7 +214,8 @@ You can now check what blocks have been created by:
var
err
error
defer
func
()
{
errCh
<-
err
}()
defer
close
(
events
)
_
,
err
=
api
.
Unixfs
()
.
Add
(
req
.
Context
,
req
.
Files
,
opts
...
)
resolvePath
,
err
:=
api
.
Unixfs
()
.
Add
(
req
.
Context
,
req
.
Files
,
opts
...
)
_
=
node
.
Reprovider
.
Provide
(
resolvePath
.
Cid
())
}()
err
=
res
.
Emit
(
events
)
...
...
exchange/reprovide/reprovide.go
浏览文件 @
226a3019
...
...
@@ -84,27 +84,39 @@ func (rp *Reprovider) Reprovide() error {
return
fmt
.
Errorf
(
"failed to get key chan: %s"
,
err
)
}
for
c
:=
range
keychan
{
// hash security
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
!=
nil
{
log
.
Errorf
(
"insecure hash in reprovider, %s (%s)"
,
c
,
err
)
continue
}
op
:=
func
()
error
{
err
:=
rp
.
rsys
.
Provide
(
rp
.
ctx
,
c
,
true
)
if
err
!=
nil
{
log
.
Debugf
(
"Failed to provide key: %s"
,
err
)
}
if
err
:=
rp
.
Provide
(
c
);
err
!=
nil
{
return
err
}
}
return
nil
}
func
(
rp
*
Reprovider
)
Provide
(
c
cid
.
Cid
)
error
{
// hash security
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
!=
nil
{
log
.
Errorf
(
"insecure hash in reprovider, %s (%s)"
,
c
,
err
)
// TODO: maybe returning nil here isn't great as it idiomatically
// indicates there was no error, even though overall it has
// the same effect
return
nil
}
// TODO: this backoff library does not respect our context, we should
// eventually work contexts into it. low priority.
err
:=
backoff
.
Retry
(
op
,
backoff
.
NewExponentialBackOff
())
op
:=
func
()
error
{
err
:=
rp
.
rsys
.
Provide
(
rp
.
ctx
,
c
,
true
)
if
err
!=
nil
{
log
.
Debugf
(
"Providing failed after number of retries: %s"
,
err
)
return
err
log
.
Debugf
(
"Failed to provide key: %s"
,
err
)
}
return
err
}
// TODO: this backoff library does not respect our context, we should
// eventually work contexts into it. low priority.
err
:=
backoff
.
Retry
(
op
,
backoff
.
NewExponentialBackOff
())
if
err
!=
nil
{
log
.
Debugf
(
"Providing failed after number of retries: %s"
,
err
)
return
err
}
return
nil
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论