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-block-format
Commits
0b506293
Commit
0b506293
authored
Jul 05, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block get returned.
parent
1832342c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
blocks.go
blocks.go
+4
-3
blocks_test.go
blocks_test.go
+5
-1
No files found.
blocks.go
View file @
0b506293
...
...
@@ -39,9 +39,10 @@ func NewBlockService(d ds.Datastore) (*BlockService, error) {
return
&
BlockService
{
Datastore
:
d
},
nil
}
func
(
s
*
BlockService
)
AddBlock
(
b
*
Block
)
error
{
dsk
:=
ds
.
NewKey
(
string
(
b
.
Key
()))
return
s
.
Datastore
.
Put
(
dsk
,
b
.
Data
)
func
(
s
*
BlockService
)
AddBlock
(
b
*
Block
)
(
u
.
Key
,
error
)
{
k
:=
b
.
Key
()
dsk
:=
ds
.
NewKey
(
string
(
k
))
return
k
,
s
.
Datastore
.
Put
(
dsk
,
b
.
Data
)
}
func
(
s
*
BlockService
)
GetBlock
(
k
u
.
Key
)
(
*
Block
,
error
)
{
...
...
blocks_test.go
View file @
0b506293
...
...
@@ -37,12 +37,16 @@ func TestBlocks(t *testing.T) {
t
.
Error
(
"Block key and data multihash key not equal"
)
}
err
=
bs
.
AddBlock
(
b
)
k
,
err
:
=
bs
.
AddBlock
(
b
)
if
err
!=
nil
{
t
.
Error
(
"failed to add block to BlockService"
,
err
)
return
}
if
k
!=
b
.
Key
()
{
t
.
Error
(
"returned key is not equal to block key"
,
err
)
}
b2
,
err
:=
bs
.
GetBlock
(
b
.
Key
())
if
err
!=
nil
{
t
.
Error
(
"failed to retrieve block from BlockService"
,
err
)
...
...
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