diff --git a/packages/relayer/indexer/detect_and_handle_reorg.go b/packages/relayer/indexer/detect_and_handle_reorg.go index fd1beb8a78b..3ff30a81073 100644 --- a/packages/relayer/indexer/detect_and_handle_reorg.go +++ b/packages/relayer/indexer/detect_and_handle_reorg.go @@ -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 } diff --git a/packages/relayer/indexer/save_message_status_changed_events.go b/packages/relayer/indexer/save_message_status_changed_events.go index d50900a4b44..f7c4beffe87 100644 --- a/packages/relayer/indexer/save_message_status_changed_events.go +++ b/packages/relayer/indexer/save_message_status_changed_events.go @@ -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{ diff --git a/packages/relayer/repo/event.go b/packages/relayer/repo/event.go index eec79c7e8a6..655b76f18c2 100644 --- a/packages/relayer/repo/event.go +++ b/packages/relayer/repo/event.go @@ -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")