diff --git a/Makefile b/Makefile index 26a572d54d..3c9ba0cd01 100644 --- a/Makefile +++ b/Makefile @@ -332,7 +332,7 @@ golangci_lint_cmd=$(DOCKER) run --rm -v $(CURDIR):/work -w /work $(containerGola lint: lint-go-diff @#if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLint}$$"; then docker start -a $(containerMarkdownLint); else docker run --name $(containerMarkdownLint) -i -v "$(CURDIR):/work" $(markdownLintImage); fi - docker run -i --rm -v "$(CURDIR):/work" $(containerMarkdownLintImage) . + docker run -i --rm -v "$(CURDIR):/work" $(containerMarkdownLintImage) -- . lint-fix: @#if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerMarkdownLintFix}$$"; then docker start -a $(containerMarkdownLintFix); else docker run --name $(containerMarkdownLintFix) -i -v "$(CURDIR):/work" $(markdownLintImage) . --fix; fi diff --git a/x/mint/abci.go b/x/mint/abci.go index 283cb57bdc..46064ba68a 100644 --- a/x/mint/abci.go +++ b/x/mint/abci.go @@ -23,9 +23,9 @@ func HandleMunicipalInflation(minter *types.Minter, params *types.Params, ctx *s // gather supply value & calculate number of new tokens created from relevant inflation totalDenomSupply := k.BankKeeper.GetSupply(*ctx, pair.Denom) - cacheItem, exists := cache.GMunicipalInflationCache.GetInflation(pair.Denom) + cacheItem := cache.GMunicipalInflationCache.GetInflation(pair.Denom) - if !exists { + if cacheItem == nil { panic(fmt.Errorf("numicipal inflation: missing cache item for the \"%s\" denomination", pair.Denom)) } diff --git a/x/mint/cache/municipal_inflation_cahe.go b/x/mint/cache/municipal_inflation_cahe.go index 5b2695b7bc..38d8a12849 100644 --- a/x/mint/cache/municipal_inflation_cahe.go +++ b/x/mint/cache/municipal_inflation_cahe.go @@ -57,14 +57,19 @@ func (cache *MunicipalInflationCache) RefreshIfNecessary(inflations *[]*types.Mu } } -func (cache *MunicipalInflationCache) GetInflation(denom string) (MunicipalInflationCacheItem, bool) { +func (cache *MunicipalInflationCache) GetInflation(denom string) *MunicipalInflationCacheItem { val := cache.internal.Load() if val == nil { - return MunicipalInflationCacheItem{}, false + return nil } infl, exists := val.(*MunicipalInflationCacheInternal).inflations[denom] - return *infl, exists + + if exists { + return infl + } + + return nil } func (cache *MunicipalInflationCache) GetOriginal() *[]*types.MunicipalInflationPair { diff --git a/x/mint/keeper/grpc_query.go b/x/mint/keeper/grpc_query.go index 8763214746..f9facec323 100644 --- a/x/mint/keeper/grpc_query.go +++ b/x/mint/keeper/grpc_query.go @@ -35,8 +35,8 @@ func (k Keeper) MunicipalInflation(c context.Context, req *types.QueryMunicipalI return &types.QueryMunicipalInflationResponse{Inflations: *cache.GMunicipalInflationCache.GetOriginal()}, nil } - infl, exists := cache.GMunicipalInflationCache.GetInflation(denom) - if !exists { + infl := cache.GMunicipalInflationCache.GetInflation(denom) + if infl == nil { return nil, fmt.Errorf("there is no municipal inflation defined for requested \"%s\" denomination", denom) }