Skip to content

Commit

Permalink
fix(relayer): make sure to return nil for first by msg hash (#13967)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey authored Jun 12, 2023
1 parent 87c6e20 commit bf69226
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/relayer/indexer/detect_and_handle_reorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func (svc *Service) detectAndHandleReorg(ctx context.Context, eventType string,
return errors.Wrap(err, "svc.eventRepo.FirstByMsgHash")
}

if e == nil {
if e == nil || e.MsgHash == "" {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (svc *Service) saveMessageStatusChangedEvent(
return errors.Wrap(err, "svc.eventRepo.FirstByMsgHash")
}

if e == nil {
return errors.Wrap(err, "svc.eventRepo.FirstByMsgHash")
if e == nil || e.MsgHash == "" {
return errors.New("message hash doesnt exist when it should")
}

_, err = svc.eventRepo.Save(ctx, relayer.SaveEventOpts{
Expand Down
2 changes: 1 addition & 1 deletion packages/relayer/repo/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (r *EventRepository) FirstByMsgHash(
if err := r.db.GormDB().Where("msg_hash = ?", msgHash).
First(&e).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return e, nil
return nil, nil
}

return nil, errors.Wrap(err, "r.db.First")
Expand Down

0 comments on commit bf69226

Please sign in to comment.