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-merkledag
Commits
8f57b7b8
Commit
8f57b7b8
authored
Oct 06, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement dagmodifier and tests.
parent
ccae0acd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
25 deletions
+22
-25
merkledag.go
merkledag.go
+22
-25
No files found.
merkledag.go
View file @
8f57b7b8
...
@@ -34,9 +34,6 @@ type Link struct {
...
@@ -34,9 +34,6 @@ type Link struct {
// cumulative size of target object
// cumulative size of target object
Size
uint64
Size
uint64
// cumulative size of data stored in object
DataSize
uint64
// multihash of the target object
// multihash of the target object
Hash
mh
.
Multihash
Hash
mh
.
Multihash
...
@@ -44,45 +41,45 @@ type Link struct {
...
@@ -44,45 +41,45 @@ type Link struct {
Node
*
Node
Node
*
Node
}
}
// AddNodeLink adds a link to another node.
func
MakeLink
(
n
*
Node
)
(
*
Link
,
error
)
{
func
(
n
*
Node
)
AddNodeLink
(
name
string
,
that
*
Node
)
error
{
s
,
err
:=
n
.
Size
()
s
,
err
:=
that
.
Size
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
h
,
err
:=
that
.
Multihash
()
h
,
err
:=
n
.
Multihash
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
nil
,
err
}
}
return
&
Link
{
n
.
Links
=
append
(
n
.
Links
,
&
Link
{
Name
:
name
,
Size
:
s
,
Size
:
s
,
Hash
:
h
,
Hash
:
h
,
Node
:
that
,
},
nil
})
return
nil
}
}
// AddNodeLink adds a link to another node. without keeping a reference to
// AddNodeLink adds a link to another node.
// the child node
func
(
n
*
Node
)
AddNodeLink
(
name
string
,
that
*
Node
)
error
{
func
(
n
*
Node
)
AddNodeLinkClean
(
name
string
,
that
*
Node
)
error
{
lnk
,
err
:=
MakeLink
(
that
)
s
,
err
:=
that
.
Size
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
lnk
.
Name
=
name
lnk
.
Node
=
that
n
.
Links
=
append
(
n
.
Links
,
lnk
)
return
nil
}
h
,
err
:=
that
.
Multihash
()
// AddNodeLink adds a link to another node. without keeping a reference to
// the child node
func
(
n
*
Node
)
AddNodeLinkClean
(
name
string
,
that
*
Node
)
error
{
lnk
,
err
:=
MakeLink
(
that
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
lnk
.
Name
=
name
n
.
Links
=
append
(
n
.
Links
,
&
Link
{
n
.
Links
=
append
(
n
.
Links
,
lnk
)
Name
:
name
,
Size
:
s
,
Hash
:
h
,
})
return
nil
return
nil
}
}
...
...
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