Skip to content

Commit b545be6

Browse files
authored
Merge pull request #18 from ipfs/feat/get-size
implement GetSize
2 parents 13c8c18 + 72c1b13 commit b545be6

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

datastore.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ func (a *accessor) Has(key ds.Key) (exists bool, err error) {
9595
return a.ldb.Has(key.Bytes(), nil)
9696
}
9797

98+
func (d *accessor) GetSize(key ds.Key) (size int, err error) {
99+
return ds.GetBackedSize(d, key)
100+
}
101+
98102
func (a *accessor) Delete(key ds.Key) (err error) {
99103
// leveldb Delete will not return an error if the key doesn't
100104
// exist (see https://github.com/syndtr/goleveldb/issues/109),

ds_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
ds "github.com/ipfs/go-datastore"
1111
dsq "github.com/ipfs/go-datastore/query"
12+
dstest "github.com/ipfs/go-datastore/test"
1213
)
1314

1415
var testcases = map[string]string{
@@ -320,3 +321,9 @@ func TestTransactionManyOperations(t *testing.T) {
320321

321322
txn.Discard()
322323
}
324+
325+
func TestSuite(t *testing.T) {
326+
d := newDSMem(t)
327+
defer d.Close()
328+
dstest.SubtestAll(t, d)
329+
}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
},
2222
{
2323
"author": "jbenet",
24-
"hash": "QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP",
24+
"hash": "QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D",
2525
"name": "go-datastore",
26-
"version": "3.3.0"
26+
"version": "3.4.0"
2727
}
2828
],
2929
"gxVersion": "0.8.0",

0 commit comments

Comments
 (0)