Merge PR #4800: Organize store keys in app.go into a map

This commit is contained in:
frog power 4000
2019-07-31 06:59:16 -07:00
committed by Alexander Bezobchuk
parent 1765613718
commit 8f09f1e2b3
11 changed files with 109 additions and 70 deletions
+20
View File
@@ -73,12 +73,32 @@ func NewKVStoreKey(name string) *KVStoreKey {
return types.NewKVStoreKey(name)
}
// 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
}
// Constructs new TransientStoreKey
// Must return a pointer according to the ocap principle
func NewTransientStoreKey(name string) *TransientStoreKey {
return types.NewTransientStoreKey(name)
}
// 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
}
// 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