Skip to content

Commit

Permalink
Wait for optimistic processing to finish (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen authored Feb 27, 2023
1 parent a0c0481 commit 6697313
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,16 +982,13 @@ func (app *App) FinalizeBlocker(ctx sdk.Context, req *abci.RequestFinalizeBlock)
ctx.Logger().Info(fmt.Sprintf("FinalizeBlock took %dms", duration/time.Millisecond))
}()

if app.optimisticProcessingInfo != nil && !app.optimisticProcessingInfo.Aborted && bytes.Equal(app.optimisticProcessingInfo.Hash, req.Hash) {
select {
case <-app.optimisticProcessingInfo.Completion:
if app.optimisticProcessingInfo != nil {
<-app.optimisticProcessingInfo.Completion
if !app.optimisticProcessingInfo.Aborted && bytes.Equal(app.optimisticProcessingInfo.Hash, req.Hash) {
app.SetProcessProposalStateToCommit()
appHash := app.WriteStateToCommitAndGetWorkingHash()
resp := app.getFinalizeBlockResponse(appHash, app.optimisticProcessingInfo.Events, app.optimisticProcessingInfo.TxRes, app.optimisticProcessingInfo.EndBlockResp)
return &resp, nil
case <-time.After(OptimisticProcessingTimeoutInSeconds * time.Second):
ctx.Logger().Info("optimistic processing timed out")
break
}
}
ctx.Logger().Info("optimistic processing ineligible")
Expand Down

0 comments on commit 6697313

Please sign in to comment.