diff --git a/CHANGELOG.md b/CHANGELOG.md index 66050728892f..6827622628f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -230,6 +230,7 @@ functionality that requires an online connection. * (simulation) [\#6002](https://github.com/cosmos/cosmos-sdk/pull/6002) Add randomized consensus params into simulation. * (x/staking) [\#6059](https://github.com/cosmos/cosmos-sdk/pull/6059) Updated `HistoricalEntries` parameter default to 100. * (x/ibc) [\#5948](https://github.com/cosmos/cosmos-sdk/issues/5948) Add `InitGenesis` and `ExportGenesis` functions for `ibc` module. +* (types) [\#6128](https://github.com/cosmos/cosmos-sdk/pull/6137) Add String() method to GasMeter ## [v0.38.3] - 2020-04-09 diff --git a/store/types/gas.go b/store/types/gas.go index a5a2c5e1d19b..c6c94f859e02 100644 --- a/store/types/gas.go +++ b/store/types/gas.go @@ -1,6 +1,9 @@ package types -import "math" +import ( + "fmt" + "math" +) // Gas consumption descriptors. const ( @@ -36,6 +39,7 @@ type GasMeter interface { ConsumeGas(amount Gas, descriptor string) IsPastLimit() bool IsOutOfGas() bool + String() string } type basicGasMeter struct { @@ -98,6 +102,10 @@ func (g *basicGasMeter) IsOutOfGas() bool { return g.consumed >= g.limit } +func (g *basicGasMeter) String() string { + return fmt.Sprintf("BasicGasMeter:\n limit: %d\n consumed: %d", g.limit, g.consumed) +} + type infiniteGasMeter struct { consumed Gas } @@ -138,6 +146,10 @@ func (g *infiniteGasMeter) IsOutOfGas() bool { return false } +func (g *infiniteGasMeter) String() string { + return fmt.Sprintf("InfiniteGasMeter:\n consumed: %d", g.consumed) +} + // GasConfig defines gas cost for each operation on KVStores type GasConfig struct { HasCost Gas