Skip to content

Commit c0ba962

Browse files
committed
Fix commit until block
1 parent 68087a0 commit c0ba962

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/orchestrator/committer.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ func (c *Committer) runCommitLoop(ctx context.Context, interval time.Duration) {
245245
log.Debug().Msg("Committer work mode not set, skipping commit")
246246
continue
247247
}
248-
if c.commitUntilBlock.Sign() > 0 && c.lastCommittedBlock.Load() > c.commitUntilBlock.Uint64() {
248+
if c.commitUntilBlock.Sign() > 0 && c.lastCommittedBlock.Load() >= c.commitUntilBlock.Uint64() {
249249
// Completing the commit loop if we've committed more than commit until block
250250
log.Info().Msgf("Committer reached configured untilBlock %s, the last commit block is %d, stopping commits", c.commitUntilBlock.String(), c.lastCommittedBlock.Load())
251251
return
@@ -399,9 +399,16 @@ func (c *Committer) getBlockNumbersToPublish(ctx context.Context) ([]*big.Int, e
399399

400400
func (c *Committer) getBlockToCommitUntil(ctx context.Context, latestCommittedBlockNumber *big.Int) (*big.Int, error) {
401401
untilBlock := new(big.Int).Add(latestCommittedBlockNumber, big.NewInt(int64(c.blocksPerCommit)))
402+
403+
// If a commit until block is set, then set a limit on the commit until block
404+
if c.commitUntilBlock.Sign() > 0 && untilBlock.Cmp(c.commitUntilBlock) > 0 {
405+
return new(big.Int).Set(c.commitUntilBlock), nil
406+
}
407+
402408
c.workModeMutex.RLock()
403409
currentMode := c.workMode
404410
c.workModeMutex.RUnlock()
411+
405412
if currentMode == WorkModeBackfill {
406413
return untilBlock, nil
407414
} else {

0 commit comments

Comments
 (0)