Skip to content

Commit

Permalink
cherry pick: 1fdb0f5
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez committed Dec 18, 2023
1 parent 099592c commit 8b4be44
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ type BaseApp struct {
// including the goroutine handling.This is experimental and must be enabled
// by developers.
optimisticExec *oe.OptimisticExecution

// StreamEvents
StreamEvents chan StreamEvents
}

// NewBaseApp returns a reference to an initialized BaseApp. It accepts a
Expand All @@ -203,6 +206,7 @@ func NewBaseApp(
txDecoder: txDecoder,
fauxMerkleMode: false,
queryGasLimit: math.MaxUint64,
StreamEvents: make(chan StreamEvents),
}

for _, option := range options {
Expand Down Expand Up @@ -719,6 +723,7 @@ func (app *BaseApp) beginBlock(req *abci.RequestFinalizeBlock) (sdk.BeginBlock,
)
}

app.AddStreamEvents(app.finalizeBlockState.ctx.BlockHeight(), resp.Events, true)
resp.Events = sdk.MarkEventsToIndex(resp.Events, app.indexEvents)
}

Expand Down Expand Up @@ -781,6 +786,7 @@ func (app *BaseApp) endBlock(ctx context.Context) (sdk.EndBlock, error) {
)
}

app.AddStreamEvents(app.finalizeBlockState.ctx.BlockHeight(), eb.Events, true)
eb.Events = sdk.MarkEventsToIndex(eb.Events, app.indexEvents)
endblock = eb
}
Expand Down
19 changes: 19 additions & 0 deletions baseapp/chain_stream.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package baseapp

import "github.com/cometbft/cometbft/abci/types"

type StreamEvents struct {
Events []types.Event
Height uint64
Flush bool
}

func (app *BaseApp) AddStreamEvents(height int64, events []types.Event, flush bool) {
go func() {
app.StreamEvents <- StreamEvents{
Events: events,
Height: uint64(height),
Flush: flush,
}
}()

Check notice

Code scanning / CodeQL

Spawning a Go routine Note

Spawning a Go routine may be a possible source of non-determinism
}

0 comments on commit 8b4be44

Please sign in to comment.