Skip to content

Commit

Permalink
fix errs
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed Oct 25, 2024
1 parent 0398644 commit 42c91a5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/services/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const (
// The method runs asynchronously to allow non-blocking operation.
func (s *Service) BootstrapBbn(ctx context.Context) {
go func() {
err := s.attemptBootstrap(ctx)
if err != nil {
if err := s.attemptBootstrap(ctx); err != nil {
log.Fatal().Msgf("BBN bootstrap process exited with error: %v", err)
}
}()
Expand Down Expand Up @@ -67,16 +66,19 @@ func (s *Service) attemptBootstrap(ctx context.Context) *types.Error {
default:
events, err := s.getEventsFromBlock(ctx, int64(i))
if err != nil {
log.Err(err).Msgf("Failed to get events from block %d", i)
return err
}
for _, event := range events {
s.bbnEventProcessor <- event
}

// Update lastProcessedHeight after successful processing
if err := s.db.UpdateLastProcessedHeight(ctx, i); err != nil {
log.Err(err).Msg("Failed to update last processed height")
if dbErr := s.db.UpdateLastProcessedHeight(ctx, i); dbErr != nil {
return types.NewError(
http.StatusInternalServerError,
types.InternalServiceError,
fmt.Errorf("failed to update last processed height in database: %w", dbErr),
)
}
lastProcessedHeight = i
}
Expand Down

0 comments on commit 42c91a5

Please sign in to comment.