2017-12-21 20:05:41 -08:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2020-01-16 13:46:51 -08:00
|
|
|
tmkv "github.com/tendermint/tendermint/libs/kv"
|
2017-12-21 20:05:41 -08:00
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
2019-02-01 17:03:09 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/store/types"
|
|
|
|
)
|
2018-07-26 18:24:18 -07:00
|
|
|
|
2019-02-01 17:03:09 -08:00
|
|
|
// nolint - reexport
|
|
|
|
type (
|
|
|
|
PruningOptions = types.PruningOptions
|
|
|
|
)
|
2017-12-21 20:05:41 -08:00
|
|
|
|
2019-02-01 17:03:09 -08:00
|
|
|
// nolint - reexport
|
|
|
|
type (
|
2019-09-04 10:33:32 -07:00
|
|
|
Store = types.Store
|
|
|
|
Committer = types.Committer
|
|
|
|
CommitStore = types.CommitStore
|
|
|
|
Queryable = types.Queryable
|
|
|
|
MultiStore = types.MultiStore
|
|
|
|
CacheMultiStore = types.CacheMultiStore
|
|
|
|
CommitMultiStore = types.CommitMultiStore
|
|
|
|
MultiStorePersistentCache = types.MultiStorePersistentCache
|
|
|
|
KVStore = types.KVStore
|
|
|
|
Iterator = types.Iterator
|
2019-02-01 17:03:09 -08:00
|
|
|
)
|
2017-12-21 20:05:41 -08:00
|
|
|
|
2019-08-13 15:16:03 -07:00
|
|
|
// StoreDecoderRegistry defines each of the modules store decoders. Used for ImportExport
|
|
|
|
// simulation.
|
2020-01-16 13:46:51 -08:00
|
|
|
type StoreDecoderRegistry map[string]func(cdc *codec.Codec, kvA, kvB tmkv.Pair) string
|
2019-08-13 15:16:03 -07:00
|
|
|
|
2018-05-26 18:00:39 -07:00
|
|
|
// Iterator over all the keys with a certain prefix in ascending order
|
|
|
|
func KVStorePrefixIterator(kvs KVStore, prefix []byte) Iterator {
|
2019-02-01 17:03:09 -08:00
|
|
|
return types.KVStorePrefixIterator(kvs, prefix)
|
2018-05-26 18:00:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Iterator over all the keys with a certain prefix in descending order.
|
|
|
|
func KVStoreReversePrefixIterator(kvs KVStore, prefix []byte) Iterator {
|
2019-02-01 17:03:09 -08:00
|
|
|
return types.KVStoreReversePrefixIterator(kvs, prefix)
|
2018-05-26 18:00:39 -07:00
|
|
|
}
|
|
|
|
|
2019-12-26 07:33:34 -08:00
|
|
|
// KVStorePrefixIteratorPaginated returns iterator over items in the selected page.
|
|
|
|
// Items iterated and skipped in ascending order.
|
|
|
|
func KVStorePrefixIteratorPaginated(kvs KVStore, prefix []byte, page, limit uint) Iterator {
|
|
|
|
return types.KVStorePrefixIteratorPaginated(kvs, prefix, page, limit)
|
|
|
|
}
|
|
|
|
|
|
|
|
// KVStoreReversePrefixIteratorPaginated returns iterator over items in the selected page.
|
|
|
|
// Items iterated and skipped in descending order.
|
|
|
|
func KVStoreReversePrefixIteratorPaginated(kvs KVStore, prefix []byte, page, limit uint) Iterator {
|
|
|
|
return types.KVStorePrefixIteratorPaginated(kvs, prefix, page, limit)
|
|
|
|
}
|
|
|
|
|
2019-07-19 07:05:37 -07:00
|
|
|
// DiffKVStores compares two KVstores and returns all the key/value pairs
|
|
|
|
// that differ from one another. It also skips value comparison for a set of provided prefixes
|
2020-01-16 13:46:51 -08:00
|
|
|
func DiffKVStores(a KVStore, b KVStore, prefixesToSkip [][]byte) (kvAs, kvBs []tmkv.Pair) {
|
2019-02-01 17:03:09 -08:00
|
|
|
return types.DiffKVStores(a, b, prefixesToSkip)
|
2017-12-21 20:05:41 -08:00
|
|
|
}
|
|
|
|
|
2019-02-01 17:03:09 -08:00
|
|
|
// nolint - reexport
|
|
|
|
type (
|
|
|
|
CacheKVStore = types.CacheKVStore
|
|
|
|
CommitKVStore = types.CommitKVStore
|
|
|
|
CacheWrap = types.CacheWrap
|
|
|
|
CacheWrapper = types.CacheWrapper
|
|
|
|
CommitID = types.CommitID
|
|
|
|
)
|
2018-01-22 05:44:24 -08:00
|
|
|
|
2019-02-01 17:03:09 -08:00
|
|
|
// nolint - reexport
|
|
|
|
type StoreType = types.StoreType
|
2018-01-22 05:44:24 -08:00
|
|
|
|
2019-02-01 17:03:09 -08:00
|
|
|
// nolint - reexport
|
2018-01-22 05:44:24 -08:00
|
|
|
const (
|
2019-02-01 17:03:09 -08:00
|
|
|
StoreTypeMulti = types.StoreTypeMulti
|
|
|
|
StoreTypeDB = types.StoreTypeDB
|
|
|
|
StoreTypeIAVL = types.StoreTypeIAVL
|
|
|
|
StoreTypeTransient = types.StoreTypeTransient
|
2018-01-22 05:44:24 -08:00
|
|
|
)
|
|
|
|
|
2019-02-01 17:03:09 -08:00
|
|
|
// nolint - reexport
|
|
|
|
type (
|
|
|
|
StoreKey = types.StoreKey
|
2020-01-30 07:13:42 -08:00
|
|
|
CapabilityKey = types.CapabilityKey
|
2019-02-01 17:03:09 -08:00
|
|
|
KVStoreKey = types.KVStoreKey
|
|
|
|
TransientStoreKey = types.TransientStoreKey
|
|
|
|
)
|
2018-01-12 13:48:54 -08:00
|
|
|
|
|
|
|
// NewKVStoreKey returns a new pointer to a KVStoreKey.
|
|
|
|
// Use a pointer so keys don't collide.
|
|
|
|
func NewKVStoreKey(name string) *KVStoreKey {
|
2019-02-01 17:03:09 -08:00
|
|
|
return types.NewKVStoreKey(name)
|
2018-01-12 13:48:54 -08:00
|
|
|
}
|
|
|
|
|
2019-07-31 06:59:16 -07:00
|
|
|
// NewKVStoreKeys returns a map of new pointers to KVStoreKey's.
|
|
|
|
// Uses pointers so keys don't collide.
|
|
|
|
func NewKVStoreKeys(names ...string) map[string]*KVStoreKey {
|
|
|
|
keys := make(map[string]*KVStoreKey)
|
|
|
|
for _, name := range names {
|
|
|
|
keys[name] = NewKVStoreKey(name)
|
|
|
|
}
|
|
|
|
return keys
|
|
|
|
}
|
|
|
|
|
2019-02-01 17:03:09 -08:00
|
|
|
// Constructs new TransientStoreKey
|
|
|
|
// Must return a pointer according to the ocap principle
|
|
|
|
func NewTransientStoreKey(name string) *TransientStoreKey {
|
|
|
|
return types.NewTransientStoreKey(name)
|
2018-01-12 13:48:54 -08:00
|
|
|
}
|
2018-04-01 09:00:28 -07:00
|
|
|
|
2019-07-31 06:59:16 -07:00
|
|
|
// NewTransientStoreKeys constructs a new map of TransientStoreKey's
|
|
|
|
// Must return pointers according to the ocap principle
|
|
|
|
func NewTransientStoreKeys(names ...string) map[string]*TransientStoreKey {
|
|
|
|
keys := make(map[string]*TransientStoreKey)
|
|
|
|
for _, name := range names {
|
|
|
|
keys[name] = NewTransientStoreKey(name)
|
|
|
|
}
|
|
|
|
return keys
|
|
|
|
}
|
|
|
|
|
2018-04-06 02:29:25 -07:00
|
|
|
// PrefixEndBytes returns the []byte that would end a
|
|
|
|
// range query for all []byte with a certain prefix
|
|
|
|
// Deals with last byte of prefix being FF without overflowing
|
2018-04-01 09:00:28 -07:00
|
|
|
func PrefixEndBytes(prefix []byte) []byte {
|
2019-02-01 17:03:09 -08:00
|
|
|
return types.PrefixEndBytes(prefix)
|
2018-04-01 09:00:28 -07:00
|
|
|
}
|
2018-05-08 09:47:31 -07:00
|
|
|
|
2018-10-07 21:43:47 -07:00
|
|
|
// InclusiveEndBytes returns the []byte that would end a
|
|
|
|
// range query such that the input would be included
|
|
|
|
func InclusiveEndBytes(inclusiveBytes []byte) (exclusiveBytes []byte) {
|
2019-02-01 17:03:09 -08:00
|
|
|
return types.InclusiveEndBytes(inclusiveBytes)
|
2018-06-21 14:33:36 -07:00
|
|
|
}
|
|
|
|
|
2018-05-08 09:47:31 -07:00
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// key-value result for iterator queries
|
2019-02-01 17:03:09 -08:00
|
|
|
type KVPair = types.KVPair
|
2018-06-21 14:33:36 -07:00
|
|
|
|
|
|
|
//----------------------------------------
|
2018-07-12 16:58:51 -07:00
|
|
|
|
|
|
|
// TraceContext contains TraceKVStore context data. It will be written with
|
|
|
|
// every trace operation.
|
2019-02-01 17:03:09 -08:00
|
|
|
type TraceContext = types.TraceContext
|
|
|
|
|
|
|
|
// --------------------------------------
|
|
|
|
|
|
|
|
// nolint - reexport
|
|
|
|
type (
|
|
|
|
Gas = types.Gas
|
|
|
|
GasMeter = types.GasMeter
|
|
|
|
GasConfig = types.GasConfig
|
|
|
|
)
|
|
|
|
|
|
|
|
// nolint - reexport
|
|
|
|
func NewGasMeter(limit Gas) GasMeter {
|
|
|
|
return types.NewGasMeter(limit)
|
|
|
|
}
|
|
|
|
|
|
|
|
// nolint - reexport
|
|
|
|
type (
|
|
|
|
ErrorOutOfGas = types.ErrorOutOfGas
|
|
|
|
ErrorGasOverflow = types.ErrorGasOverflow
|
|
|
|
)
|
|
|
|
|
|
|
|
// nolint - reexport
|
|
|
|
func NewInfiniteGasMeter() GasMeter {
|
|
|
|
return types.NewInfiniteGasMeter()
|
|
|
|
}
|