Address PR comments
This commit is contained in:
parent
97efff8af6
commit
26a31926f8
|
@ -11,6 +11,8 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/stake/types"
|
||||
)
|
||||
|
||||
const aminoCacheSize = 500
|
||||
|
||||
// keeper of the stake store
|
||||
type Keeper struct {
|
||||
storeKey sdk.StoreKey
|
||||
|
@ -34,7 +36,7 @@ func NewKeeper(cdc *codec.Codec, key, tkey sdk.StoreKey, ck bank.Keeper, paramst
|
|||
bankKeeper: ck,
|
||||
paramstore: paramstore.WithTypeTable(ParamTypeTable()),
|
||||
hooks: nil,
|
||||
validatorCache: make(map[string]cachedValidator, 500),
|
||||
validatorCache: make(map[string]cachedValidator, aminoCacheSize),
|
||||
validatorCacheList: list.New(),
|
||||
codespace: codespace,
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func (k Keeper) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator ty
|
|||
k.validatorCacheList.PushBack(cachedVal)
|
||||
|
||||
// if the cache is too big, pop off the last element from it
|
||||
if k.validatorCacheList.Len() > 500 {
|
||||
if k.validatorCacheList.Len() > aminoCacheSize {
|
||||
valToRemove := k.validatorCacheList.Remove(k.validatorCacheList.Front()).(cachedValidator)
|
||||
delete(k.validatorCache, valToRemove.marshalled)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue