Skip to content

Commit

Permalink
Fix expectedStarBlock once restarted using cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBger committed May 16, 2024
1 parent 31ce216 commit 74eb975
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sinker.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewFileSinker(sinker *sink.Sinker, bundler *bundler.Bundler, encoder encode
func (fs *FileSinker) Run(ctx context.Context) error {
cursor, err := fs.bundler.GetCursor()
if err != nil {
return fmt.Errorf("faile to read curosor: %w", err)
return fmt.Errorf("faile to read cursor: %w", err)
}

fs.Sinker.OnTerminating(fs.Shutdown)
Expand All @@ -58,13 +58,13 @@ func (fs *FileSinker) Run(ctx context.Context) error {

expectedStartBlock := uint64(0)
if !cursor.IsBlank() {
expectedStartBlock = cursor.Block().Num()
expectedStartBlock = cursor.Block().Num() + 1
} else if blockRange := fs.BlockRange(); blockRange != nil {
expectedStartBlock = blockRange.StartBlock()
}

if err := fs.bundler.Start(expectedStartBlock); err != nil {
return fmt.Errorf("unable to start bunlder: %w", err)
return fmt.Errorf("unable to start bundler: %w", err)
}

fs.logger.Info("starting file sink", zap.Stringer("restarting_at", cursor.Block()))
Expand Down

0 comments on commit 74eb975

Please sign in to comment.