Skip to content

Commit

Permalink
tbc: tidy up if/else (use early return for ErrNotFound)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuasing committed Jun 24, 2024
1 parent 0de4ef2 commit c0a5662
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions service/tbc/tbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1589,17 +1589,17 @@ func (s *Server) Run(pctx context.Context) error {
// Find out where IBD is at
bhb, err := s.db.BlockHeaderBest(ctx)
if err != nil {
if errors.Is(err, database.ErrNotFound) {
if err = s.insertGenesis(ctx); err != nil {
return fmt.Errorf("insert genesis: %w", err)
}
bhb, err = s.db.BlockHeaderBest(ctx)
if err != nil {
return err
}
} else {
if !errors.Is(err, database.ErrNotFound) {
return fmt.Errorf("block headers best: %w", err)
}

if err = s.insertGenesis(ctx); err != nil {
return fmt.Errorf("insert genesis: %w", err)
}
bhb, err = s.db.BlockHeaderBest(ctx)
if err != nil {
return err
}
}
log.Infof("Starting block headers sync at height: %v time %v",
bhb.Height, bhb.Timestamp())
Expand Down

0 comments on commit c0a5662

Please sign in to comment.