Skip to content

Commit

Permalink
only detect reorg not crawling
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Mar 2, 2024
1 parent 6f847a3 commit 199ea82
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/relayer/indexer/handle_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ func (i *Indexer) handleEvent(
return nil
}

// check if we have seen this event and msgHash before - if we have, it is being reorged.
if err := i.detectAndHandleReorg(ctx, relayer.EventNameMessageSent, common.Hash(event.MsgHash).Hex()); err != nil {
return errors.Wrap(err, "svc.detectAndHandleReorg")
}

// we should never see an empty msgHash, but if we do, we dont process.
if event.MsgHash == relayer.ZeroHash {
slog.Warn("Zero msgHash found. This is unexpected. Returning early")
Expand All @@ -61,6 +56,11 @@ func (i *Indexer) handleEvent(
// only wait for confirmations when not crawling past blocks.
// these are guaranteed to be confirmed since the blocks are old.
if i.watchMode != CrawlPastBlocks {
// check if we have seen this event and msgHash before - if we have, it is being reorged.
if err := i.detectAndHandleReorg(ctx, relayer.EventNameMessageSent, common.Hash(event.MsgHash).Hex()); err != nil {
return errors.Wrap(err, "svc.detectAndHandleReorg")
}

// we need to wait for confirmations to confirm this event is not being reverted,
// removed, or reorged now.
confCtx, confCtxCancel := context.WithTimeout(ctx, defaultCtxTimeout)
Expand Down

0 comments on commit 199ea82

Please sign in to comment.