Pass gas consumed back in result struct
This commit is contained in:
parent
f0e4d24ea3
commit
ddb3b36b7b
|
@ -322,6 +322,7 @@ func (app *BaseApp) CheckTx(txBytes []byte) (res abci.ResponseCheckTx) {
|
|||
Data: result.Data,
|
||||
Log: result.Log,
|
||||
GasWanted: result.GasWanted,
|
||||
GasUsed: result.GasUsed,
|
||||
Fee: cmn.KI64Pair{
|
||||
[]byte(result.FeeDenom),
|
||||
result.FeeAmount,
|
||||
|
@ -433,6 +434,9 @@ func (app *BaseApp) runTx(isCheckTx bool, txBytes []byte, tx sdk.Tx) (result sdk
|
|||
|
||||
result = handler(ctx, msg)
|
||||
|
||||
// Set gas utilized
|
||||
result.GasUsed = ctx.GasMeter().GasConsumed()
|
||||
|
||||
// If result was successful, write to app.checkState.ms or app.deliverState.ms
|
||||
if result.IsOK() {
|
||||
msCache.Write()
|
||||
|
|
|
@ -2,10 +2,11 @@ package types
|
|||
|
||||
import ()
|
||||
|
||||
type Gas uint64
|
||||
type Gas = int64
|
||||
|
||||
type GasMeter interface {
|
||||
GasExceeded() bool
|
||||
GasConsumed() Gas
|
||||
ConsumeGas(amount Gas)
|
||||
ConsumeGasOrFail(amount Gas) bool
|
||||
}
|
||||
|
@ -26,6 +27,10 @@ func (g *basicGasMeter) GasExceeded() bool {
|
|||
return g.consumed > g.limit
|
||||
}
|
||||
|
||||
func (g *basicGasMeter) GasConsumed() Gas {
|
||||
return g.consumed
|
||||
}
|
||||
|
||||
func (g *basicGasMeter) ConsumeGas(amount Gas) {
|
||||
g.consumed += amount
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue