Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
183a92b6
Commit
183a92b6
authored
Dec 26, 2018
by
Bamvor Zhang
Committed by
Lucas Molas
Jan 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dag: remove the old FillNodeLayer
License: MIT Signed-off-by:
Bamvor Zhang
<
jian.zhang@ipfsbit.com
>
parent
032dcd44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
23 deletions
+5
-23
importer/helpers/dagbuilder.go
importer/helpers/dagbuilder.go
+2
-20
importer/trickle/trickledag.go
importer/trickle/trickledag.go
+3
-3
No files found.
importer/helpers/dagbuilder.go
View file @
183a92b6
...
...
@@ -228,26 +228,8 @@ func (db *DagBuilderHelper) newUnixfsBlock() *UnixfsNode {
}
// FillNodeLayer will add datanodes as children to the give node until
// at most db.indirSize nodes are added.
func
(
db
*
DagBuilderHelper
)
FillNodeLayer
(
node
*
UnixfsNode
)
error
{
// while we have room AND we're not done
for
node
.
NumChildren
()
<
db
.
maxlinks
&&
!
db
.
Done
()
{
child
,
err
:=
db
.
GetNextDataNode
()
if
err
!=
nil
{
return
err
}
if
err
:=
node
.
AddChild
(
child
,
db
);
err
!=
nil
{
return
err
}
}
return
nil
}
// FillFSNodeLayer do the same thing as FillNodeLayer.
func
(
db
*
DagBuilderHelper
)
FillFSNodeLayer
(
node
*
FSNodeOverDag
)
error
{
// it is full in this layer or no more data.
func
(
db
*
DagBuilderHelper
)
FillNodeLayer
(
node
*
FSNodeOverDag
)
error
{
// while we have room AND we're not done
for
node
.
NumChildren
()
<
db
.
maxlinks
&&
!
db
.
Done
()
{
...
...
importer/trickle/trickledag.go
View file @
183a92b6
...
...
@@ -51,7 +51,7 @@ func Layout(db *h.DagBuilderHelper) (ipld.Node, error) {
// (where the DAG builder will signal the end of data to end the function).
func
fillTrickleRec
(
db
*
h
.
DagBuilderHelper
,
node
*
h
.
FSNodeOverDag
,
maxDepth
int
)
(
filledNode
ipld
.
Node
,
nodeFileSize
uint64
,
err
error
)
{
// Always do this, even in the base case
if
err
:=
db
.
Fill
FS
NodeLayer
(
node
);
err
!=
nil
{
if
err
:=
db
.
FillNodeLayer
(
node
);
err
!=
nil
{
return
nil
,
0
,
err
}
...
...
@@ -105,7 +105,7 @@ func Append(ctx context.Context, basen ipld.Node, db *h.DagBuilderHelper) (out i
n
,
layerProgress
:=
trickleDepthInfo
(
fsn
,
db
.
Maxlinks
())
if
n
==
0
{
// If direct blocks not filled...
if
err
:=
db
.
Fill
FS
NodeLayer
(
fsn
);
err
!=
nil
{
if
err
:=
db
.
FillNodeLayer
(
fsn
);
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -204,7 +204,7 @@ func appendRec(ctx context.Context, fsn *h.FSNodeOverDag, db *h.DagBuilderHelper
n
,
layerProgress
:=
trickleDepthInfo
(
fsn
,
db
.
Maxlinks
())
if
n
==
0
{
// If direct blocks not filled...
if
err
:=
db
.
Fill
FS
NodeLayer
(
fsn
);
err
!=
nil
{
if
err
:=
db
.
FillNodeLayer
(
fsn
);
err
!=
nil
{
return
nil
,
0
,
err
}
n
++
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment