Skip to content

Commit

Permalink
Remove Overkill Flushing
Browse files Browse the repository at this point in the history
  • Loading branch information
joelsmith-2019 committed Apr 11, 2024
1 parent b315d4c commit 62a68aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ethereum/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,20 @@ func (e *Ethereum) flushMechanism(
case <-timer.C:
latestBlock := e.LatestBlock()

// initialize first lastFlushedBlock if not set
if e.lastFlushedBlock == 0 {
e.lastFlushedBlock = latestBlock
e.lastFlushedBlock = latestBlock - e.lookbackPeriod
}

start := e.lastFlushedBlock - e.lookbackPeriod
// start from lastFlushedBlock
start := e.lastFlushedBlock

logger.Info(fmt.Sprintf("Flush started from %d to %d", start, latestBlock))

// consume from lastFlushedBlock to the latestBlock
e.getAndConsumeHistory(ctx, logger, processingQueue, messageSent, messageTransmitterAddress, messageTransmitterABI, start, latestBlock)

// update lastFlushedBlock to the last block it flushed
e.lastFlushedBlock = latestBlock

logger.Info("Flush complete")
Expand Down

0 comments on commit 62a68aa

Please sign in to comment.