BadgerDatabase GetS

This commit is contained in:
andrew 2019-11-07 15:55:21 +01:00
parent b419f35a17
commit 26cb9bd33b
3 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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)

View File

@ -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