Skip to content

Commit

Permalink
implement GetSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Oct 4, 2018
1 parent 13c8c18 commit 72c1b13
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func (a *accessor) Has(key ds.Key) (exists bool, err error) {
return a.ldb.Has(key.Bytes(), nil)
}

func (d *accessor) GetSize(key ds.Key) (size int, err error) {
return ds.GetBackedSize(d, key)
}

func (a *accessor) Delete(key ds.Key) (err error) {
// leveldb Delete will not return an error if the key doesn't
// exist (see https://github.com/syndtr/goleveldb/issues/109),
Expand Down
7 changes: 7 additions & 0 deletions ds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

ds "github.com/ipfs/go-datastore"
dsq "github.com/ipfs/go-datastore/query"
dstest "github.com/ipfs/go-datastore/test"
)

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

txn.Discard()
}

func TestSuite(t *testing.T) {
d := newDSMem(t)
defer d.Close()
dstest.SubtestAll(t, d)
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
},
{
"author": "jbenet",
"hash": "QmbQshXLNcCPRUGZv4sBGxnZNAHREA6MKeomkwihNXPZWP",
"hash": "QmaRb5yNXKonhbkpNxNawoydk4N6es6b4fPj19sjEKsh5D",
"name": "go-datastore",
"version": "3.3.0"
"version": "3.4.0"
}
],
"gxVersion": "0.8.0",
Expand Down

0 comments on commit 72c1b13

Please sign in to comment.