mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-26 03:01:42 +00:00
db: Simplify exists check, fix IsKeyInDomain signature, Iterator Close
+ *FSDB.HasKey now uses common.FileExists to test for file existence + IsKeyInDomain takes key as a []byte slice instead of as a string to avoid extraneous []byte<-->string conversions for start and end + Iterator.Close() instead of Iterator.Release() + withDB helper to encapsulate DB creation, deferred cleanups so that for loops can use opened DBs and discard them ASAP Addressing accepted changes from review with @jaekwon
This commit is contained in:
@ -2,7 +2,6 @@ package db
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func IteratePrefix(db DB, prefix []byte) Iterator {
|
||||
@ -39,8 +38,8 @@ func cpIncr(bz []byte) (ret []byte) {
|
||||
return EndingKey()
|
||||
}
|
||||
|
||||
func IsKeyInDomain(key string, start, end []byte) bool {
|
||||
leftCondition := bytes.Equal(start, BeginningKey()) || strings.Compare(key, string(start)) >= 0
|
||||
rightCondition := bytes.Equal(end, EndingKey()) || strings.Compare(key, string(end)) < 0
|
||||
func IsKeyInDomain(key, start, end []byte) bool {
|
||||
leftCondition := bytes.Equal(start, BeginningKey()) || bytes.Compare(key, start) >= 0
|
||||
rightCondition := bytes.Equal(end, EndingKey()) || bytes.Compare(key, end) < 0
|
||||
return leftCondition && rightCondition
|
||||
}
|
||||
|
Reference in New Issue
Block a user