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
c5917bc1
Commit
c5917bc1
authored
May 05, 2016
by
Kevin Atkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make blocks.Block an interface.
License: MIT Signed-off-by:
Kevin Atkinson
<
k@kevina.org
>
parent
0a178a49
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
11 deletions
+11
-11
merkledag.go
merkledag.go
+11
-11
No files found.
merkledag.go
View file @
c5917bc1
...
...
@@ -52,13 +52,13 @@ func (n *dagService) Add(nd *Node) (key.Key, error) {
return
""
,
err
}
b
:=
new
(
blocks
.
Block
)
b
.
Data
=
d
b
.
Multihash
,
err
=
nd
.
Multihash
()
mh
,
err
:=
nd
.
Multihash
()
if
err
!=
nil
{
return
""
,
err
}
b
,
_
:=
blocks
.
NewBlockWithHash
(
d
,
mh
)
return
n
.
Blocks
.
AddBlock
(
b
)
}
...
...
@@ -82,7 +82,7 @@ func (n *dagService) Get(ctx context.Context, k key.Key) (*Node, error) {
return
nil
,
fmt
.
Errorf
(
"Failed to get block for %s: %v"
,
k
.
B58String
(),
err
)
}
res
,
err
:=
DecodeProtobuf
(
b
.
Data
)
res
,
err
:=
DecodeProtobuf
(
b
.
Data
()
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to decode Protocol Buffers: %v"
,
err
)
}
...
...
@@ -135,7 +135,7 @@ func (ds *dagService) GetMany(ctx context.Context, keys []key.Key) <-chan *NodeO
}
return
}
nd
,
err
:=
DecodeProtobuf
(
b
.
Data
)
nd
,
err
:=
DecodeProtobuf
(
b
.
Data
()
)
if
err
!=
nil
{
out
<-
&
NodeOption
{
Err
:
err
}
return
...
...
@@ -316,7 +316,7 @@ func (np *nodePromise) Get(ctx context.Context) (*Node, error) {
type
Batch
struct
{
ds
*
dagService
blocks
[]
*
blocks
.
Block
blocks
[]
blocks
.
Block
size
int
MaxSize
int
}
...
...
@@ -327,17 +327,17 @@ func (t *Batch) Add(nd *Node) (key.Key, error) {
return
""
,
err
}
b
:=
new
(
blocks
.
Block
)
b
.
Data
=
d
b
.
Multihash
,
err
=
nd
.
Multihash
()
mh
,
err
:=
nd
.
Multihash
()
if
err
!=
nil
{
return
""
,
err
}
k
:=
key
.
Key
(
b
.
Multihash
)
b
,
_
:=
blocks
.
NewBlockWithHash
(
d
,
mh
)
k
:=
key
.
Key
(
mh
)
t
.
blocks
=
append
(
t
.
blocks
,
b
)
t
.
size
+=
len
(
b
.
Data
)
t
.
size
+=
len
(
b
.
Data
()
)
if
t
.
size
>
t
.
MaxSize
{
return
k
,
t
.
Commit
()
}
...
...
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