Skip to content

Commit

Permalink
renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Sep 24, 2024
1 parent 014207e commit 20805d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions rollup/rollup_sync_service/rollup_sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ func (s *RollupSyncService) fetchRollupEvents() {
return
}

log.Trace("Sync service fetch rollup events", "latest processed block", s.latestProcessedBlock.Load(), "latest confirmed", latestConfirmed)
initialProcessedBlock := s.latestProcessedBlock.Load()
currentProcessedBlock := initialProcessedBlock

latestProcessedBlock := s.latestProcessedBlock.Load()
updatedLatestProcessedBlock := latestProcessedBlock
log.Trace("Sync service fetch rollup events", "latest processed block", currentProcessedBlock, "latest confirmed", latestConfirmed)

// query in batches
for from := latestProcessedBlock + 1; from <= latestConfirmed; from += defaultFetchBlockRange {
for from := currentProcessedBlock + 1; from <= latestConfirmed; from += defaultFetchBlockRange {
if s.ctx.Err() != nil {
log.Info("Context canceled", "reason", s.ctx.Err())
return
Expand All @@ -204,10 +204,10 @@ func (s *RollupSyncService) fetchRollupEvents() {
return
}

updatedLatestProcessedBlock = to
currentProcessedBlock = to
}

s.latestProcessedBlock.CompareAndSwap(latestProcessedBlock, updatedLatestProcessedBlock)
s.latestProcessedBlock.CompareAndSwap(initialProcessedBlock, currentProcessedBlock)
}

func (s *RollupSyncService) parseAndUpdateRollupEventLogs(logs []types.Log, endBlockNumber uint64) error {
Expand Down
16 changes: 8 additions & 8 deletions rollup/sync_service/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ func (s *SyncService) fetchMessages() {
return
}

latestProcessedBlock := s.latestProcessedBlock.Load()
updatedLatestProcessedBlock := latestProcessedBlock
initialProcessedBlock := s.latestProcessedBlock.Load()
currentProcessedBlock := initialProcessedBlock

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

// keep track of next queue index we're expecting to see
queueIndex := rawdb.ReadHighestSyncedQueueIndex(s.db)
Expand Down Expand Up @@ -197,15 +197,15 @@ func (s *SyncService) fetchMessages() {
numMessagesPendingDbWrite = 0
}

updatedLatestProcessedBlock = lastBlock
currentProcessedBlock = lastBlock
}

// ticker for logging progress
t := time.NewTicker(LogProgressInterval)
numMsgsCollected := 0

// query in batches
for from := updatedLatestProcessedBlock + 1; from <= latestConfirmed; from += DefaultFetchBlockRange {
for from := currentProcessedBlock + 1; from <= latestConfirmed; from += DefaultFetchBlockRange {
select {
case <-s.ctx.Done():
// flush pending writes to database
Expand All @@ -214,8 +214,8 @@ func (s *SyncService) fetchMessages() {
}
return
case <-t.C:
progress := 100 * float64(updatedLatestProcessedBlock) / float64(latestConfirmed)
log.Info("Syncing L1 messages", "processed", updatedLatestProcessedBlock, "confirmed", latestConfirmed, "collected", numMsgsCollected, "progress(%)", progress)
progress := 100 * float64(currentProcessedBlock) / float64(latestConfirmed)
log.Info("Syncing L1 messages", "processed", currentProcessedBlock, "confirmed", latestConfirmed, "collected", numMsgsCollected, "progress(%)", progress)
default:
}

Expand Down Expand Up @@ -260,5 +260,5 @@ func (s *SyncService) fetchMessages() {
}
}

s.latestProcessedBlock.CompareAndSwap(latestProcessedBlock, updatedLatestProcessedBlock)
s.latestProcessedBlock.CompareAndSwap(initialProcessedBlock, currentProcessedBlock)
}

0 comments on commit 20805d0

Please sign in to comment.