Skip to content

Commit

Permalink
cherry pick: d5f931f
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed Dec 19, 2023
1 parent ebf5a40 commit 562218d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
11 changes: 8 additions & 3 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
}
Expand Down
18 changes: 11 additions & 7 deletions baseapp/chain_stream.go
Original file line number Diff line number Diff line change
@@ -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,
}
}
}

0 comments on commit 562218d

Please sign in to comment.