Skip to content

Commit

Permalink
fix(relayer): only wait for confirmations when not crawling past bloc…
Browse files Browse the repository at this point in the history
…ks (#16228)
  • Loading branch information
cyberhorsey authored Mar 2, 2024
1 parent 3416d9b commit ae26d8a
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions packages/relayer/indexer/handle_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,23 @@ func (i *Indexer) handleEvent(
return nil
}

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

defer confCtxCancel()

if err := relayer.WaitConfirmations(
confCtx,
i.srcEthClient,
uint64(defaultConfirmations),
event.Raw.TxHash,
); err != nil {
return err
// only wait for confirmations when not crawling past blocks.
// these are guaranteed to be confirmed since the blocks are old.
if i.watchMode != CrawlPastBlocks {
// we need to wait for confirmations to confirm this event is not being reverted,
// removed, or reorged now.
confCtx, confCtxCancel := context.WithTimeout(ctx, defaultCtxTimeout)

defer confCtxCancel()

if err := relayer.WaitConfirmations(
confCtx,
i.srcEthClient,
uint64(defaultConfirmations),
event.Raw.TxHash,
); err != nil {
return err
}
}

// get event status from msgHash on chain
Expand Down

0 comments on commit ae26d8a

Please sign in to comment.