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
4f728223
Commit
4f728223
authored
Mar 11, 2015
by
Tommi Virtanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dead code cleanup: remove AllKeys from blockstore
Nothing uses it.
parent
0ef353be
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
25 deletions
+13
-25
blockstore.go
blockstore.go
+0
-19
blockstore_test.go
blockstore_test.go
+13
-2
write_cache.go
write_cache.go
+0
-4
No files found.
blockstore.go
View file @
4f728223
...
...
@@ -31,7 +31,6 @@ type Blockstore interface {
Get
(
u
.
Key
)
(
*
blocks
.
Block
,
error
)
Put
(
*
blocks
.
Block
)
error
AllKeys
(
ctx
context
.
Context
)
([]
u
.
Key
,
error
)
AllKeysChan
(
ctx
context
.
Context
)
(
<-
chan
u
.
Key
,
error
)
}
...
...
@@ -82,24 +81,6 @@ func (s *blockstore) DeleteBlock(k u.Key) error {
return
s
.
datastore
.
Delete
(
k
.
DsKey
())
}
// AllKeys runs a query for keys from the blockstore.
// this is very simplistic, in the future, take dsq.Query as a param?
//
// AllKeys respects context
func
(
bs
*
blockstore
)
AllKeys
(
ctx
context
.
Context
)
([]
u
.
Key
,
error
)
{
ch
,
err
:=
bs
.
AllKeysChan
(
ctx
)
if
err
!=
nil
{
return
nil
,
err
}
var
keys
[]
u
.
Key
for
k
:=
range
ch
{
keys
=
append
(
keys
,
k
)
}
return
keys
,
nil
}
// AllKeysChan runs a query for keys from the blockstore.
// this is very simplistic, in the future, take dsq.Query as a param?
//
...
...
blockstore_test.go
View file @
4f728223
...
...
@@ -63,14 +63,24 @@ func newBlockStoreWithKeys(t *testing.T, d ds.Datastore, N int) (Blockstore, []u
return
bs
,
keys
}
func
collect
(
ch
<-
chan
u
.
Key
)
[]
u
.
Key
{
var
keys
[]
u
.
Key
for
k
:=
range
ch
{
keys
=
append
(
keys
,
k
)
}
return
keys
}
func
TestAllKeysSimple
(
t
*
testing
.
T
)
{
bs
,
keys
:=
newBlockStoreWithKeys
(
t
,
nil
,
100
)
ctx
:=
context
.
Background
()
keys2
,
err
:=
bs
.
AllKeys
(
ctx
)
ch
,
err
:=
bs
.
AllKeys
Chan
(
ctx
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
keys2
:=
collect
(
ch
)
// for _, k2 := range keys2 {
// t.Log("found ", k2.Pretty())
// }
...
...
@@ -90,10 +100,11 @@ func TestAllKeysRespectsContext(t *testing.T) {
getKeys
:=
func
(
ctx
context
.
Context
)
{
started
<-
struct
{}{}
_
,
err
:=
bs
.
AllKeys
(
ctx
)
// once without cancelling
ch
,
err
:=
bs
.
AllKeys
Chan
(
ctx
)
// once without cancelling
if
err
!=
nil
{
errors
<-
err
}
_
=
collect
(
ch
)
done
<-
struct
{}{}
errors
<-
nil
// a nil one to signal break
}
...
...
write_cache.go
View file @
4f728223
...
...
@@ -45,10 +45,6 @@ func (w *writecache) Put(b *blocks.Block) error {
return
w
.
blockstore
.
Put
(
b
)
}
func
(
w
*
writecache
)
AllKeys
(
ctx
context
.
Context
)
([]
u
.
Key
,
error
)
{
return
w
.
blockstore
.
AllKeys
(
ctx
)
}
func
(
w
*
writecache
)
AllKeysChan
(
ctx
context
.
Context
)
(
<-
chan
u
.
Key
,
error
)
{
return
w
.
blockstore
.
AllKeysChan
(
ctx
)
}
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