Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
076d0bd9
提交
076d0bd9
authored
3月 24, 2017
作者:
Kevin Atkinson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merkeldag: change SetPrefix param to a pointer and reset the prefix on nil
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
上级
518adec0
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
22 行增加
和
14 行删除
+22
-14
add.go
core/commands/add.go
+1
-1
add.go
core/coreunix/add.go
+2
-1
dagbuilder.go
importer/helpers/dagbuilder.go
+3
-3
helpers.go
importer/helpers/helpers.go
+1
-1
node.go
merkledag/node.go
+12
-5
dir.go
mfs/dir.go
+1
-1
system.go
mfs/system.go
+1
-1
dirbuilder.go
unixfs/io/dirbuilder.go
+1
-1
没有找到文件。
core/commands/add.go
浏览文件 @
076d0bd9
...
...
@@ -236,7 +236,7 @@ You can now refer to the added file in a gateway, like so:
fileAdder
.
Silent
=
silent
fileAdder
.
RawLeaves
=
rawblks
fileAdder
.
NoCopy
=
nocopy
fileAdder
.
Prefix
=
prefix
fileAdder
.
Prefix
=
&
prefix
if
hash
{
md
:=
dagtest
.
Mock
()
...
...
core/coreunix/add.go
浏览文件 @
076d0bd9
...
...
@@ -103,7 +103,7 @@ type Adder struct {
mroot
*
mfs
.
Root
unlocker
bs
.
Unlocker
tempRoot
*
cid
.
Cid
Prefix
cid
.
Prefix
Prefix
*
cid
.
Prefix
}
func
(
adder
*
Adder
)
mfsRoot
()
(
*
mfs
.
Root
,
error
)
{
...
...
@@ -113,6 +113,7 @@ func (adder *Adder) mfsRoot() (*mfs.Root, error) {
rnode
:=
unixfs
.
EmptyDirNode
()
rnode
.
SetPrefix
(
adder
.
Prefix
)
mr
,
err
:=
mfs
.
NewRoot
(
adder
.
ctx
,
adder
.
dagService
,
rnode
,
nil
)
mr
.
Prefix
=
adder
.
Prefix
if
err
!=
nil
{
return
nil
,
err
}
...
...
importer/helpers/dagbuilder.go
浏览文件 @
076d0bd9
...
...
@@ -25,7 +25,7 @@ type DagBuilderHelper struct {
batch
*
dag
.
Batch
fullPath
string
stat
os
.
FileInfo
prefix
cid
.
Prefix
prefix
*
cid
.
Prefix
}
type
DagBuilderParams
struct
{
...
...
@@ -36,8 +36,8 @@ type DagBuilderParams struct {
// instead of using the unixfs TRaw type
RawLeaves
bool
// CID Prefix to use
Prefix
cid
.
Prefix
// CID Prefix to use
if set
Prefix
*
cid
.
Prefix
// DAGService to write blocks to (required)
Dagserv
dag
.
DAGService
...
...
importer/helpers/helpers.go
浏览文件 @
076d0bd9
...
...
@@ -62,7 +62,7 @@ func NewUnixfsNodeFromDag(nd *dag.ProtoNode) (*UnixfsNode, error) {
},
nil
}
func
(
n
*
UnixfsNode
)
SetPrefix
(
prefix
cid
.
Prefix
)
{
func
(
n
*
UnixfsNode
)
SetPrefix
(
prefix
*
cid
.
Prefix
)
{
n
.
node
.
SetPrefix
(
prefix
)
}
...
...
merkledag/node.go
浏览文件 @
076d0bd9
...
...
@@ -53,10 +53,17 @@ func PrefixForCidVersion(version int) (cid.Prefix, error) {
}
}
func
(
n
*
ProtoNode
)
SetPrefix
(
prefix
cid
.
Prefix
)
{
n
.
Prefix
=
prefix
n
.
encoded
=
nil
n
.
cached
=
nil
// SetPrefix sets the prefix if it is non nil, if prefix is nil then
// it resets it the default value
func
(
n
*
ProtoNode
)
SetPrefix
(
prefix
*
cid
.
Prefix
)
{
if
prefix
==
nil
{
n
.
Prefix
=
v0CidPrefix
}
else
{
n
.
Prefix
=
*
prefix
n
.
Prefix
.
Codec
=
cid
.
DagProtobuf
n
.
encoded
=
nil
n
.
cached
=
nil
}
}
type
LinkSlice
[]
*
node
.
Link
...
...
@@ -287,7 +294,7 @@ func (n *ProtoNode) Cid() *cid.Cid {
}
if
n
.
Prefix
.
Codec
==
0
{
n
.
Prefix
=
v0CidPrefix
n
.
SetPrefix
(
nil
)
}
c
,
err
:=
n
.
Prefix
.
Sum
(
n
.
RawData
())
...
...
mfs/dir.go
浏览文件 @
076d0bd9
...
...
@@ -58,7 +58,7 @@ func NewDirectory(ctx context.Context, name string, node node.Node, parent child
},
nil
}
func
(
d
*
Directory
)
SetPrefix
(
prefix
cid
.
Prefix
)
{
func
(
d
*
Directory
)
SetPrefix
(
prefix
*
cid
.
Prefix
)
{
d
.
dirbuilder
.
SetPrefix
(
prefix
)
}
...
...
mfs/system.go
浏览文件 @
076d0bd9
...
...
@@ -63,7 +63,7 @@ type Root struct {
Type
string
// Prefix to use for any children created
Prefix
cid
.
Prefix
Prefix
*
cid
.
Prefix
}
type
PubFunc
func
(
context
.
Context
,
*
cid
.
Cid
)
error
...
...
unixfs/io/dirbuilder.go
浏览文件 @
076d0bd9
...
...
@@ -81,7 +81,7 @@ func NewDirectoryFromNode(dserv mdag.DAGService, nd node.Node) (*Directory, erro
}
// SetPrefix sets the prefix of the root node
func
(
d
*
Directory
)
SetPrefix
(
prefix
cid
.
Prefix
)
{
func
(
d
*
Directory
)
SetPrefix
(
prefix
*
cid
.
Prefix
)
{
if
d
.
dirnode
!=
nil
{
d
.
dirnode
.
SetPrefix
(
prefix
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论