Skip to content

Commit

Permalink
fix a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Sep 24, 2024
1 parent e42e4c4 commit 0556725
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion rollup/rollup_sync_service/rollup_sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ func (s *RollupSyncService) fetchRollupEvents() {

initialProcessedBlock := s.latestProcessedBlock.Load()
currentProcessedBlock := initialProcessedBlock
defer s.latestProcessedBlock.CompareAndSwap(initialProcessedBlock, currentProcessedBlock)
// func() ensures using final currentProcessedBlock value when function returns
defer func() {
s.latestProcessedBlock.CompareAndSwap(initialProcessedBlock, currentProcessedBlock)
}()

log.Trace("Sync service fetch rollup events", "latest processed block", currentProcessedBlock, "latest confirmed", latestConfirmed)

Expand Down
5 changes: 4 additions & 1 deletion rollup/sync_service/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ func (s *SyncService) fetchMessages() {

initialProcessedBlock := s.latestProcessedBlock.Load()
currentProcessedBlock := initialProcessedBlock
defer s.latestProcessedBlock.CompareAndSwap(initialProcessedBlock, currentProcessedBlock)
// func() ensures using final currentProcessedBlock value when function returns
defer func() {
s.latestProcessedBlock.CompareAndSwap(initialProcessedBlock, currentProcessedBlock)
}()

log.Trace("Sync service fetchMessages", "latestProcessedBlock", currentProcessedBlock, "latestConfirmed", latestConfirmed)

Expand Down

0 comments on commit 0556725

Please sign in to comment.