Skip to content

Commit

Permalink
sequenver-update-04-fix-ds-batch-end (#1179)
Browse files Browse the repository at this point in the history
  • Loading branch information
kstoykov authored Sep 16, 2024
1 parent 304c548 commit af45559
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions zk/stages/stage_sequence_execute_data_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,12 @@ func (sbc *SequencerBatchStreamWriter) writeBlockDetailsToDatastream(verifiedBun
}

func alignExecutionToDatastream(batchContext *BatchContext, batchState *BatchState, lastExecutedBlock uint64, u stagedsync.Unwinder) (bool, error) {
lastExecutedBatch := batchState.batchNumber - 1
lastStartedDatastreamBatch, err := batchContext.cfg.datastreamServer.GetHighestBatchNumber()
if err != nil {
return false, err
}

lastDatastreamBatch, err := batchContext.cfg.datastreamServer.GetHighestClosedBatch()
lastClosedDatastreamBatch, err := batchContext.cfg.datastreamServer.GetHighestClosedBatch()
if err != nil {
return false, err
}
Expand All @@ -122,8 +125,8 @@ func alignExecutionToDatastream(batchContext *BatchContext, batchState *BatchSta
return false, err
}

if lastExecutedBatch != lastDatastreamBatch {
if err := finalizeLastBatchInDatastreamIfNotFinalized(batchContext, lastExecutedBatch, lastDatastreamBlock); err != nil {
if lastStartedDatastreamBatch != lastClosedDatastreamBatch {
if err := finalizeLastBatchInDatastreamIfNotFinalized(batchContext, lastStartedDatastreamBatch, lastDatastreamBlock); err != nil {
return false, err
}
}
Expand Down

0 comments on commit af45559

Please sign in to comment.