refactor(baseapp): improve readability of preblock (#21179)
This commit is contained in:
parent
6d4097bfb7
commit
ca8122c3f3
@ -786,10 +786,11 @@ func (app *BaseApp) internalFinalizeBlock(ctx context.Context, req *abci.Finaliz
|
||||
WithHeaderHash(req.Hash))
|
||||
}
|
||||
|
||||
if err := app.preBlock(req); err != nil {
|
||||
preblockEvents, err := app.preBlock(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
events = append(events, app.finalizeBlockState.ctx.EventManager().ABCIEvents()...)
|
||||
events = append(events, preblockEvents...)
|
||||
|
||||
beginBlock, err := app.beginBlock(req)
|
||||
if err != nil {
|
||||
|
||||
@ -709,11 +709,12 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context
|
||||
return ctx.WithMultiStore(msCache), msCache
|
||||
}
|
||||
|
||||
func (app *BaseApp) preBlock(req *abci.FinalizeBlockRequest) error {
|
||||
func (app *BaseApp) preBlock(req *abci.FinalizeBlockRequest) ([]abci.Event, error) {
|
||||
var events []abci.Event
|
||||
if app.preBlocker != nil {
|
||||
ctx := app.finalizeBlockState.Context()
|
||||
if err := app.preBlocker(ctx, req); err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
// ConsensusParams can change in preblocker, so we need to
|
||||
// write the consensus parameters in store to context
|
||||
@ -722,8 +723,9 @@ func (app *BaseApp) preBlock(req *abci.FinalizeBlockRequest) error {
|
||||
gasMeter := app.getBlockGasMeter(ctx)
|
||||
ctx = ctx.WithBlockGasMeter(gasMeter)
|
||||
app.finalizeBlockState.SetContext(ctx)
|
||||
events = ctx.EventManager().ABCIEvents()
|
||||
}
|
||||
return nil
|
||||
return events, nil
|
||||
}
|
||||
|
||||
func (app *BaseApp) beginBlock(_ *abci.FinalizeBlockRequest) (sdk.BeginBlock, error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user