Minor refactor to reduce complexity, add nolint
This commit is contained in:
parent
99e91dd276
commit
472e168a72
|
@ -522,8 +522,18 @@ func validateBasicTxMsgs(msgs []sdk.Msg) sdk.Error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns deliverState if app is in runTxModeDeliver, otherwhise returns checkstate
|
||||||
|
func getState(app *BaseApp, mode runTxMode) *state {
|
||||||
|
if mode == runTxModeCheck || mode == runTxModeSimulate {
|
||||||
|
return app.checkState
|
||||||
|
} else {
|
||||||
|
return app.deliverState
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// txBytes may be nil in some cases, eg. in tests.
|
// txBytes may be nil in some cases, eg. in tests.
|
||||||
// Also, in the future we may support "internal" transactions.
|
// Also, in the future we may support "internal" transactions.
|
||||||
|
// nolint: gocyclo
|
||||||
func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk.Result) {
|
func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk.Result) {
|
||||||
//NOTE: GasWanted should be returned by the AnteHandler.
|
//NOTE: GasWanted should be returned by the AnteHandler.
|
||||||
// GasUsed is determined by the GasMeter.
|
// GasUsed is determined by the GasMeter.
|
||||||
|
@ -567,17 +577,9 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk
|
||||||
gasWanted = anteResult.GasWanted
|
gasWanted = anteResult.GasWanted
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the correct cache
|
// Get the correct cache, CacheWrap app.checkState.ms in case it fails.
|
||||||
var msCache sdk.CacheMultiStore
|
msCache := getState(app, mode).CacheMultiStore()
|
||||||
if mode == runTxModeCheck || mode == runTxModeSimulate {
|
ctx = ctx.WithMultiStore(msCache)
|
||||||
// CacheWrap app.checkState.ms in case it fails.
|
|
||||||
msCache = app.checkState.CacheMultiStore()
|
|
||||||
ctx = ctx.WithMultiStore(msCache)
|
|
||||||
} else {
|
|
||||||
// CacheWrap app.deliverState.ms in case it fails.
|
|
||||||
msCache = app.deliverState.CacheMultiStore()
|
|
||||||
ctx = ctx.WithMultiStore(msCache)
|
|
||||||
}
|
|
||||||
|
|
||||||
// accumulate results
|
// accumulate results
|
||||||
logs := make([]string, 0, len(msgs))
|
logs := make([]string, 0, len(msgs))
|
||||||
|
|
Loading…
Reference in New Issue