diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index d86a816e5a00..0d45f03efd42 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -724,7 +724,9 @@ func (app *BaseApp) beginBlock(req *abci.RequestFinalizeBlock) (sdk.BeginBlock, ) } - app.AddStreamEvents(app.finalizeBlockState.ctx.BlockHeight(), resp.Events, true) + ctx := app.finalizeBlockState.ctx + app.AddStreamEvents(ctx.BlockHeight(), ctx.BlockTime(), resp.Events, true) + resp.Events = sdk.MarkEventsToIndex(resp.Events, app.indexEvents) } @@ -757,7 +759,8 @@ func (app *BaseApp) deliverTx(tx []byte) *abci.ExecTxResult { return resp } - app.AddStreamEvents(app.checkState.Context().BlockHeight(), result.Events, false) + ctx := app.checkState.Context() + app.AddStreamEvents(ctx.BlockHeight(), ctx.BlockTime(), result.Events, false) resp = &abci.ExecTxResult{ GasWanted: int64(gInfo.GasWanted), @@ -789,7 +792,9 @@ func (app *BaseApp) endBlock(ctx context.Context) (sdk.EndBlock, error) { ) } - app.AddStreamEvents(app.finalizeBlockState.ctx.BlockHeight(), eb.Events, true) + ctx := app.finalizeBlockState.ctx + app.AddStreamEvents(ctx.BlockHeight(), ctx.BlockTime(), eb.Events, true) + eb.Events = sdk.MarkEventsToIndex(eb.Events, app.indexEvents) endblock = eb } diff --git a/baseapp/chain_stream.go b/baseapp/chain_stream.go index 59b9678e0053..91d31d0e7771 100644 --- a/baseapp/chain_stream.go +++ b/baseapp/chain_stream.go @@ -1,21 +1,25 @@ package baseapp import ( + "time" + abci "github.com/cometbft/cometbft/abci/types" ) type StreamEvents struct { - Events []abci.Event - Height uint64 - Flush bool + Events []abci.Event + Height uint64 + BlockTime time.Time + Flush bool } -func (app *BaseApp) AddStreamEvents(height int64, events []abci.Event, flush bool) { +func (app *BaseApp) AddStreamEvents(height int64, blockTime time.Time, events []abci.Event, flush bool) { if app.EnableStreamer { app.StreamEvents <- StreamEvents{ - Events: events, - Height: uint64(height), - Flush: flush, + Events: events, + Height: uint64(height), + BlockTime: blockTime, + Flush: flush, } } }