Skip to content

Commit

Permalink
syncservice: allow for dtl to be switched out while syncing (ethereum…
Browse files Browse the repository at this point in the history
  • Loading branch information
tynes authored Mar 4, 2021
1 parent 99fa66c commit 460c41f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions rollup/sync_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,9 @@ func (s *SyncService) syncTransactionsToTip() error {
// First query the latest transaction
latest, err := s.client.GetLatestTransaction()
if err != nil {
return fmt.Errorf("Cannot get latest transaction: %w", err)
log.Error("Cannot get latest transaction", "msg", err)
time.Sleep(time.Second * 2)
continue
}
if latest == nil {
log.Info("No transactions to sync")
Expand All @@ -453,12 +455,17 @@ func (s *SyncService) syncTransactionsToTip() error {
for i := start; i <= *tipHeight; i++ {
tx, err := s.client.GetTransaction(i)
if err != nil {
return fmt.Errorf("Cannot get transaction: %w", err)
log.Error("Cannot get transaction", "index", i, "msg", err)
time.Sleep(time.Second * 2)
continue
}
// The transaction does not yet exist in the ctc
if tx == nil {
log.Info("Transaction in ctc does not yet exist", "index", i)
return nil
index := latest.GetMeta().Index
if index == nil {
return fmt.Errorf("Unexpected nil index")
}
return fmt.Errorf("Transaction %d not found when %d is latest", i, *index)
}
err = s.maybeApplyTransaction(tx)
if err != nil {
Expand Down

0 comments on commit 460c41f

Please sign in to comment.