From 26a31926f8b5b579e7dd09c5f6982c58642bfd33 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Tue, 11 Dec 2018 13:10:42 -0800 Subject: [PATCH] Address PR comments --- x/stake/keeper/keeper.go | 4 +++- x/stake/keeper/validator.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/x/stake/keeper/keeper.go b/x/stake/keeper/keeper.go index b53190398..93b75958d 100644 --- a/x/stake/keeper/keeper.go +++ b/x/stake/keeper/keeper.go @@ -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, } diff --git a/x/stake/keeper/validator.go b/x/stake/keeper/validator.go index 8dca50389..b762e1c46 100644 --- a/x/stake/keeper/validator.go +++ b/x/stake/keeper/validator.go @@ -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) }