-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,32 @@ | ||
package types | ||
|
||
import ( | ||
"fmt" | ||
v1 "github.com/cosmos/cosmos-sdk/store/types" | ||
) | ||
|
||
var PrefixEndBytes = v1.PrefixEndBytes | ||
|
||
// // Iterator over all the keys with a certain prefix in ascending order | ||
// func KVStorePrefixIterator(kvs KVStore, prefix []byte) Iterator { | ||
// return kvs.Iterator(prefix, PrefixEndBytes(prefix)) | ||
// } | ||
|
||
// // Iterator over all the keys with a certain prefix in descending order. | ||
// func KVStoreReversePrefixIterator(kvs KVStore, prefix []byte) Iterator { | ||
// return kvs.ReverseIterator(prefix, PrefixEndBytes(prefix)) | ||
// } | ||
|
||
func StoreKeyToType(key StoreKey) (typ StoreType, err error) { | ||
switch key.(type) { | ||
case *KVStoreKey: | ||
typ = StoreTypePersistent | ||
case *MemoryStoreKey: | ||
typ = StoreTypeMemory | ||
case *TransientStoreKey: | ||
typ = StoreTypeTransient | ||
default: | ||
err = fmt.Errorf("unrecognized store key type: %T", key) | ||
} | ||
return | ||
} |