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 {
// cumulative size of target object
Size
uint64
// cumulative size of data stored in object
DataSize
uint64
// multihash of the target object
Hash
mh
.
Multihash
...
...
@@ -44,45 +41,45 @@ type Link struct {
Node
*
Node
}
// AddNodeLink adds a link to another node.
func
(
n
*
Node
)
AddNodeLink
(
name
string
,
that
*
Node
)
error
{
s
,
err
:=
that
.
Size
()
func
MakeLink
(
n
*
Node
)
(
*
Link
,
error
)
{
s
,
err
:=
n
.
Size
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
h
,
err
:=
that
.
Multihash
()
h
,
err
:=
n
.
Multihash
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
n
.
Links
=
append
(
n
.
Links
,
&
Link
{
Name
:
name
,
return
&
Link
{
Size
:
s
,
Hash
:
h
,
Node
:
that
,
})
return
nil
},
nil
}
// AddNodeLink adds a link to another node. without keeping a reference to
// the child node
func
(
n
*
Node
)
AddNodeLinkClean
(
name
string
,
that
*
Node
)
error
{
s
,
err
:=
that
.
Size
()
// AddNodeLink adds a link to another node.
func
(
n
*
Node
)
AddNodeLink
(
name
string
,
that
*
Node
)
error
{
lnk
,
err
:=
MakeLink
(
that
)
if
err
!=
nil
{
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
{
return
err
}
lnk
.
Name
=
name
n
.
Links
=
append
(
n
.
Links
,
&
Link
{
Name
:
name
,
Size
:
s
,
Hash
:
h
,
})
n
.
Links
=
append
(
n
.
Links
,
lnk
)
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