Skip to content

Commit

Permalink
Problem: fireEvents can runs asyncously (#4)
Browse files Browse the repository at this point in the history
changelog
  • Loading branch information
yihuang authored Nov 1, 2024
1 parent 0319b60 commit f2b043f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/unreleased/improvements/4-async-fire-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `[consensus]` run fireEvents in goroutine.
([#4](https://github.com/crypto-org-chain/cometbft/pull/4))

8 changes: 5 additions & 3 deletions state/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,11 @@ func (blockExec *BlockExecutor) applyBlock(state State, blockID types.BlockID, b
}
}

// Events are fired after everything else.
// NOTE: if we crash between Commit and Save, events wont be fired during replay
fireEvents(blockExec.logger, blockExec.eventBus, block, blockID, abciResponse, validatorUpdates)
if _, ok := blockExec.eventBus.(types.NopEventBus); !ok {
// Events are fired after everything else.
// NOTE: if we crash between Commit and Save, events wont be fired during replay
go fireEvents(blockExec.logger, blockExec.eventBus, block, blockID, abciResponse, validatorUpdates)
}

return state, nil
}
Expand Down

0 comments on commit f2b043f

Please sign in to comment.