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-blockservice
Commits
034441cf
Commit
034441cf
authored
Jun 26, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use batching transaction interface from datastore
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
db38dad0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
blockservice.go
blockservice.go
+16
-0
No files found.
blockservice.go
View file @
034441cf
...
@@ -77,6 +77,22 @@ func (s *BlockService) AddBlock(b *blocks.Block) (key.Key, error) {
...
@@ -77,6 +77,22 @@ func (s *BlockService) AddBlock(b *blocks.Block) (key.Key, error) {
return
k
,
nil
return
k
,
nil
}
}
func
(
s
*
BlockService
)
AddBlocks
(
bs
[]
*
blocks
.
Block
)
([]
key
.
Key
,
error
)
{
err
:=
s
.
Blockstore
.
PutMany
(
bs
)
if
err
!=
nil
{
return
nil
,
err
}
var
ks
[]
key
.
Key
for
_
,
b
:=
range
bs
{
if
err
:=
s
.
worker
.
HasBlock
(
b
);
err
!=
nil
{
return
nil
,
errors
.
New
(
"blockservice is closed"
)
}
ks
=
append
(
ks
,
b
.
Key
())
}
return
ks
,
nil
}
// GetBlock retrieves a particular block from the service,
// GetBlock retrieves a particular block from the service,
// Getting it from the datastore using the key (hash).
// Getting it from the datastore using the key (hash).
func
(
s
*
BlockService
)
GetBlock
(
ctx
context
.
Context
,
k
key
.
Key
)
(
*
blocks
.
Block
,
error
)
{
func
(
s
*
BlockService
)
GetBlock
(
ctx
context
.
Context
,
k
key
.
Key
)
(
*
blocks
.
Block
,
error
)
{
...
...
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