Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [Cometic] Municipal Inflation Cache - update code comment #163

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions x/mint/cache/municipal_inflation_cahe.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cache

import (

Check failure on line 3 in x/mint/cache/municipal_inflation_cahe.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/mint/types"
"sync"

Check failure on line 6 in x/mint/cache/municipal_inflation_cahe.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
)

type MunicipalInflationCacheItem struct {
Expand All @@ -18,13 +18,17 @@
mu sync.RWMutex
}

var (

Check failure on line 21 in x/mint/cache/municipal_inflation_cahe.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
// NOTE(pb): This is *NOT* thread safe.
// However, in our case, this global variable is by design
// *NOT* supposed to be accessed simultaneously in multiple
// different threads, or in global scope somewhere else.
// Once such requirements arise, concept of this global variable
// needs to be changed to something what is thread safe.
// GMunicipalInflationCache Thread safety:
// As the things stand now from design & impl. perspective:
// 1. This global variable is supposed to be initialised(= its value set)
// just *ONCE* here, at this place,
// 2. This global variable is *NOT* used anywhere else in the initialisation
// context of the *global scope* - e.g. as input for initialisation of
// another global variable, etc. ...
// 3. All *exported* methods of `MunicipalInflationCache` type *ARE* thread safe,
// and so can be called from anywhere, *EXCEPT* from the initialisation context
// of the global scope(implication of the point 2 above)!
GMunicipalInflationCache = MunicipalInflationCache{}
)

Expand Down Expand Up @@ -74,7 +78,7 @@

for _, pair := range *inflations {
inflationPerBlock, err := types.CalculateInflationPerBlock(pair.Inflation.Value, blocksPerYear)

Check failure on line 81 in x/mint/cache/municipal_inflation_cahe.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofumpt`-ed (gofumpt)
if err != nil {
panic(err)
}
Expand Down
Loading