Skip to content

Commit

Permalink
setup reorg cb
Browse files Browse the repository at this point in the history
  • Loading branch information
joanestebanr committed May 16, 2024
1 parent 0d8e489 commit ed82d25
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion synchronizer/synchronizer_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type SynchronizerImpl struct {
l1EventProcessors *processor_manager.L1EventProcessors
blockRangeProcessor syncinterfaces.BlockRangeProcessor
l1Sync *l1sync.L1SequentialSync

reorgCallback func(newFirstL1BlockNumberValid uint64)
}

// NewSynchronizer creates and initializes an instance of Synchronizer
Expand Down Expand Up @@ -111,11 +113,15 @@ func (s *SynchronizerImpl) IsSynced() bool {

func (s *SynchronizerImpl) SetCallbackOnReorgDone(callback func(newFirstL1BlockNumberValid uint64)) {
//TODO: Implement this function
log.Fatal("Not implemented")
s.reorgCallback = callback
}

func (s *SynchronizerImpl) OnReorgExecuted(reorg model.ReorgExecutionResult) {
log.Infof("Reorg executed! %s", reorg.String())
if s.reorgCallback != nil {
s.reorgCallback(reorg.Request.FirstL1BlockNumberToKeep)
}

}

// Sync function will read the last state synced and will continue from that point.
Expand Down

0 comments on commit ed82d25

Please sign in to comment.