mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 04:03:49 +00:00
BadgerDatabase Has
This commit is contained in:
parent
81d0d84ed4
commit
109217a9da
@ -189,7 +189,7 @@ func (db *BadgerDatabase) DeleteTimestamp(timestamp uint64) error {
|
||||
})
|
||||
}
|
||||
|
||||
// GetS returns the value that was put into a given historical bucket for an exact timestamp.
|
||||
// GetS returns the value that was recorded in 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)
|
||||
@ -228,4 +228,13 @@ func (db *BadgerDatabase) GetAsOf(bucket, hBucket, key []byte, timestamp uint64)
|
||||
return dat, err
|
||||
}
|
||||
|
||||
// Has indicates whether a key exists in the database.
|
||||
func (db *BadgerDatabase) Has(bucket, key []byte) (bool, error) {
|
||||
_, err := db.Get(bucket, key)
|
||||
if err == ErrKeyNotFound {
|
||||
return false, nil
|
||||
}
|
||||
return err == nil, err
|
||||
}
|
||||
|
||||
// TODO [Andrew] implement the full Database interface
|
||||
|
@ -182,7 +182,7 @@ func (db *BoltDatabase) Get(bucket, key []byte) ([]byte, error) {
|
||||
return dat, err
|
||||
}
|
||||
|
||||
// GetS returns the value that was put into a given historical bucket for an exact timestamp.
|
||||
// GetS returns the value that was recorded in 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)
|
||||
|
@ -42,7 +42,7 @@ type Getter interface {
|
||||
// Get returns the value for a given key if it's present.
|
||||
Get(bucket, key []byte) ([]byte, error)
|
||||
|
||||
// GetS returns the value that was put into a given historical bucket for an exact timestamp.
|
||||
// GetS returns the value that was recorded in a given historical bucket for an exact timestamp.
|
||||
// timestamp == block number
|
||||
GetS(hBucket, key []byte, timestamp uint64) ([]byte, error)
|
||||
|
||||
@ -50,7 +50,9 @@ type Getter interface {
|
||||
// timestamp == block number
|
||||
GetAsOf(bucket, hBucket, key []byte, timestamp uint64) ([]byte, error)
|
||||
|
||||
// Has indicates whether a key exists in the database.
|
||||
Has(bucket, key []byte) (bool, error)
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user