From 0eb9d3915bb2327ff311f66b5bb6215f85481e7c Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 14 Nov 2019 13:00:38 +0100 Subject: [PATCH] Add method stubs to BadgerDatabase so it formally implements the Database interface --- ethdb/badger_db.go | 44 ++++++++++++++++++++++++++++++++++++++++++ ethdb/database_test.go | 2 +- ethdb/interface.go | 3 +-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/ethdb/badger_db.go b/ethdb/badger_db.go index 633ffcdd6..7c9f7978e 100644 --- a/ethdb/badger_db.go +++ b/ethdb/badger_db.go @@ -281,3 +281,47 @@ func (db *BadgerDatabase) Walk(bucket, startkey []byte, fixedbits uint, walker f } // TODO [Andrew] implement the full Database interface + +func (db *BadgerDatabase) MultiWalk(bucket []byte, startkeys [][]byte, fixedbits []uint, walker func(int, []byte, []byte) (bool, error)) error { + panic("Not implemented") +} + +func (db *BadgerDatabase) WalkAsOf(bucket, hBucket, startkey []byte, fixedbits uint, timestamp uint64, walker func([]byte, []byte) (bool, error)) error { + panic("Not implemented") +} + +func (db *BadgerDatabase) MultiWalkAsOf(bucket, hBucket []byte, startkeys [][]byte, fixedbits []uint, timestamp uint64, walker func(int, []byte, []byte) (bool, error)) error { + panic("Not implemented") +} + +func (db *BadgerDatabase) MultiPut(tuples ...[]byte) (uint64, error) { + panic("Not implemented") +} + +func (db *BadgerDatabase) RewindData(timestampSrc, timestampDst uint64, df func(bucket, key, value []byte) error) error { + panic("Not implemented") +} + +func (db *BadgerDatabase) NewBatch() DbWithPendingMutations { + panic("Not implemented") +} + +func (db *BadgerDatabase) Size() int { + panic("Not implemented") +} + +func (db *BadgerDatabase) Keys() ([][]byte, error) { + panic("Not implemented") +} + +func (db *BadgerDatabase) MemCopy() Database { + panic("Not implemented") +} + +func (db *BadgerDatabase) Ancients() (uint64, error) { + panic("Not implemented") +} + +func (db *BadgerDatabase) TruncateAncients(items uint64) error { + panic("Not implemented") +} diff --git a/ethdb/database_test.go b/ethdb/database_test.go index 070c64043..519c92f16 100644 --- a/ethdb/database_test.go +++ b/ethdb/database_test.go @@ -273,7 +273,7 @@ var fixedBits uint = 3 var keysInRange = [][]byte{common.FromHex("a8"), common.FromHex("bb"), common.FromHex("bd")} -func testWalk(db MinDatabase, t *testing.T) { +func testWalk(db Database, t *testing.T) { for k, v := range hexEntries { err := db.Put(bucket, common.FromHex(k), common.FromHex(v)) if err != nil { diff --git a/ethdb/interface.go b/ethdb/interface.go index 8f5c2e8a4..b70ba9098 100644 --- a/ethdb/interface.go +++ b/ethdb/interface.go @@ -61,6 +61,7 @@ type Getter interface { // walker is called for each eligible entry. // If walker returns false or an error, the walk stops. Walk(bucket, startkey []byte, fixedbits uint, walker func([]byte, []byte) (bool, error)) error + MultiWalk(bucket []byte, startkeys [][]byte, fixedbits []uint, walker func(int, []byte, []byte) (bool, error)) error WalkAsOf(bucket, hBucket, startkey []byte, fixedbits uint, timestamp uint64, walker func([]byte, []byte) (bool, error)) error MultiWalkAsOf(bucket, hBucket []byte, startkeys [][]byte, fixedbits []uint, timestamp uint64, walker func(int, []byte, []byte) (bool, error)) error @@ -99,8 +100,6 @@ type MinDatabase interface { Get(bucket, key []byte) ([]byte, error) Put(bucket, key, value []byte) error Delete(bucket, key []byte) error - - Walk(bucket, startkey []byte, fixedbits uint, walker func([]byte, []byte) (bool, error)) error } // DbWithPendingMutations is an extended version of the Database,