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-dms3-blockstore
Commits
cf153d24
Commit
cf153d24
authored
Dec 06, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blockstore: Put checks Has first.
parent
68d0beb8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletion
+7
-1
blockstore.go
blockstore.go
+7
-1
No files found.
blockstore.go
View file @
cf153d24
...
@@ -45,7 +45,13 @@ func (bs *blockstore) Get(k u.Key) (*blocks.Block, error) {
...
@@ -45,7 +45,13 @@ func (bs *blockstore) Get(k u.Key) (*blocks.Block, error) {
}
}
func
(
bs
*
blockstore
)
Put
(
block
*
blocks
.
Block
)
error
{
func
(
bs
*
blockstore
)
Put
(
block
*
blocks
.
Block
)
error
{
return
bs
.
datastore
.
Put
(
block
.
Key
()
.
DsKey
(),
block
.
Data
)
// Has is cheaper than
k
:=
block
.
Key
()
.
DsKey
()
exists
,
err
:=
bs
.
datastore
.
Has
(
k
)
if
err
!=
nil
&&
exists
{
return
nil
// already stored.
}
return
bs
.
datastore
.
Put
(
k
,
block
.
Data
)
}
}
func
(
bs
*
blockstore
)
Has
(
k
u
.
Key
)
(
bool
,
error
)
{
func
(
bs
*
blockstore
)
Has
(
k
u
.
Key
)
(
bool
,
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