Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,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

Expand Down
14 changes: 13 additions & 1 deletion store/types/gas.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package types

import "math"
import (
"fmt"
"math"
)

// Gas consumption descriptors.
const (
Expand Down Expand Up @@ -36,6 +39,7 @@ type GasMeter interface {
ConsumeGas(amount Gas, descriptor string)
IsPastLimit() bool
IsOutOfGas() bool
String() string
}

type basicGasMeter struct {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -138,6 +146,10 @@ func (g *infiniteGasMeter) IsOutOfGas() bool {
return false
}

func (g *infiniteGasMeter) String() string {
return fmt.Sprintf("BasicGasMeter:\n consumed: %d", g.consumed)
}

// GasConfig defines gas cost for each operation on KVStores
type GasConfig struct {
HasCost Gas
Expand Down