cosmos-sdk/baseapp/context.go

31 lines
736 B
Go
Raw Normal View History

2018-01-24 11:47:51 -08:00
package baseapp
import sdk "github.com/cosmos/cosmos-sdk/types"
// Returns a new Context suitable for AnteHandler (and indirectly Handler) processing.
2018-01-26 04:19:33 -08:00
// NOTE: txBytes may be nil to support TestApp.RunCheckTx
// and TestApp.RunDeliverTx.
func (app *BaseApp) newContext(isCheckTx bool, txBytes []byte) sdk.Context {
2018-01-24 11:47:51 -08:00
var store sdk.MultiStore
if isCheckTx {
store = app.msCheck
} else {
store = app.msDeliver
}
2018-01-24 12:11:14 -08:00
if store == nil {
panic("BaseApp.NewContext() requires BeginBlock(): missing store")
}
if app.header == nil {
panic("BaseApp.NewContext() requires BeginBlock(): missing header")
}
2018-01-24 11:47:51 -08:00
// Initialize arguments to Handler.
var ctx = sdk.NewContext(
store,
2018-01-24 12:11:14 -08:00
*app.header,
2018-01-24 11:47:51 -08:00
isCheckTx,
txBytes,
)
return ctx
}