From 199ea824ed96877d89567c7bf57c0b51a551b4bc Mon Sep 17 00:00:00 2001 From: Jeffery Walsh Date: Sat, 2 Mar 2024 11:40:29 -0800 Subject: [PATCH] only detect reorg not crawling --- packages/relayer/indexer/handle_event.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/relayer/indexer/handle_event.go b/packages/relayer/indexer/handle_event.go index c07be55bf8e..7e4abac0690 100644 --- a/packages/relayer/indexer/handle_event.go +++ b/packages/relayer/indexer/handle_event.go @@ -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") @@ -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)