address some comments while reviewing Jaes work

This commit is contained in:
rigelrozanski 2018-11-22 00:30:04 -05:00
parent 972377c287
commit b4b61b890c
2 changed files with 6 additions and 2 deletions

View File

@ -136,6 +136,7 @@ func (app *BaseApp) MountStore(key sdk.StoreKey, typ sdk.StoreType) {
}
// load latest application version
// panics if called more than once on a running baseapp
func (app *BaseApp) LoadLatestVersion(mainKey *sdk.KVStoreKey) error {
err := app.cms.LoadLatestVersion()
if err != nil {
@ -145,6 +146,7 @@ func (app *BaseApp) LoadLatestVersion(mainKey *sdk.KVStoreKey) error {
}
// load application version
// panics if called more than once on a running baseapp
func (app *BaseApp) LoadVersion(version int64, mainKey *sdk.KVStoreKey) error {
err := app.cms.LoadVersion(version)
if err != nil {
@ -702,7 +704,9 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
}
}
// consume block gas whether panic or not.
// If BlockGasMeter() panics it will be caught by the above recover and
// return an error - in any case BlockGasMeter will consume gas past
// the limit.
if mode == runTxModeDeliver {
ctx.BlockGasMeter().ConsumeGas(
ctx.GasMeter().GasConsumedToLimit(), "block gas meter")

View File

@ -63,7 +63,7 @@ func (g *basicGasMeter) Limit() Gas {
}
func (g *basicGasMeter) GasConsumedToLimit() Gas {
if g.consumed > g.limit {
if g.IsPastLimit() {
return g.limit
}
return g.consumed