diff --git a/ethdb/badger_db.go b/ethdb/badger_db.go index 864b87eab..0851896cf 100644 --- a/ethdb/badger_db.go +++ b/ethdb/badger_db.go @@ -186,4 +186,10 @@ func (db *BadgerDatabase) DeleteTimestamp(timestamp uint64) error { }) } +// GetS returns a single value that was put into a given historical bucket for an exact timestamp. +func (db *BadgerDatabase) GetS(hBucket, key []byte, timestamp uint64) ([]byte, error) { + composite, _ := dbutils.CompositeKeySuffix(key, timestamp) + return db.Get(hBucket, composite) +} + // TODO [Andrew] implement the full Database interface diff --git a/ethdb/bolt_db.go b/ethdb/bolt_db.go index 79134516a..c97b0b812 100644 --- a/ethdb/bolt_db.go +++ b/ethdb/bolt_db.go @@ -186,6 +186,7 @@ func (db *BoltDatabase) Get(bucket, key []byte) ([]byte, error) { return dat, err } +// GetS returns a single value that was put into a given historical bucket for an exact timestamp. func (db *BoltDatabase) GetS(hBucket, key []byte, timestamp uint64) ([]byte, error) { composite, _ := dbutils.CompositeKeySuffix(key, timestamp) return db.Get(hBucket, composite) diff --git a/ethdb/interface.go b/ethdb/interface.go index 46c4e3cce..c8eba1493 100644 --- a/ethdb/interface.go +++ b/ethdb/interface.go @@ -35,7 +35,11 @@ type Putter interface { type Getter interface { // Get returns a single value. Get(bucket, key []byte) ([]byte, error) + + // GetS returns a single value that was put into a given historical bucket for an exact timestamp. + // timestamp == block number GetS(hBucket, key []byte, timestamp uint64) ([]byte, error) + GetAsOf(bucket, hBucket, key []byte, timestamp uint64) ([]byte, error) Has(bucket, key []byte) (bool, error) Walk(bucket, startkey []byte, fixedbits uint, walker func([]byte, []byte) (bool, error)) error