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
939ac997
Commit
939ac997
authored
Sep 04, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue with blocks not actually being stored via dagservice
parent
9dd615bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
2 deletions
+25
-2
merkledag.go
merkledag.go
+25
-2
No files found.
merkledag.go
View file @
939ac997
...
...
@@ -55,6 +55,7 @@ func (n *Node) AddNodeLink(name string, that *Node) error {
Name
:
name
,
Size
:
s
,
Hash
:
h
,
Node
:
that
,
})
return
nil
}
...
...
@@ -97,8 +98,10 @@ type DAGService struct {
Blocks
*
bserv
.
BlockService
}
// Put adds a node to the DAGService, storing the block in the BlockService
func
(
n
*
DAGService
)
Put
(
nd
*
Node
)
(
u
.
Key
,
error
)
{
// Add adds a node to the DAGService, storing the block in the BlockService
func
(
n
*
DAGService
)
Add
(
nd
*
Node
)
(
u
.
Key
,
error
)
{
k
,
_
:=
nd
.
Key
()
u
.
DOut
(
"DagService Add [%s]
\n
"
,
k
.
Pretty
())
if
n
==
nil
{
return
""
,
fmt
.
Errorf
(
"DAGService is nil"
)
}
...
...
@@ -116,6 +119,26 @@ func (n *DAGService) Put(nd *Node) (u.Key, error) {
return
n
.
Blocks
.
AddBlock
(
b
)
}
func
(
n
*
DAGService
)
AddRecursive
(
nd
*
Node
)
error
{
_
,
err
:=
n
.
Add
(
nd
)
if
err
!=
nil
{
return
err
}
for
_
,
link
:=
range
nd
.
Links
{
fmt
.
Println
(
"Adding link."
)
if
link
.
Node
==
nil
{
panic
(
"Why does this node have a nil link?
\n
"
)
}
err
:=
n
.
AddRecursive
(
link
.
Node
)
if
err
!=
nil
{
return
err
}
}
return
nil
}
// Get retrieves a node from the DAGService, fetching the block in the BlockService
func
(
n
*
DAGService
)
Get
(
k
u
.
Key
)
(
*
Node
,
error
)
{
if
n
==
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