Skip to content

Commit

Permalink
err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ettec committed Dec 9, 2024
1 parent 4829aca commit f6786cd
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions core/services/relay/evm/read/multieventtype.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@ type EventQuery struct {
}

func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueries []EventQuery, limitAndSort query.LimitAndSort) (iter.Seq2[string, commontypes.Sequence], error) {
seqIter, err := multiEventTypeQueryWithoutErrorWrapping(ctx, lp, eventQueries, limitAndSort)
if err != nil {
return nil, newMultiEventTypeQueryError(eventQueries, err)
}

return seqIter, nil
}

func multiEventTypeQueryWithoutErrorWrapping(ctx context.Context, lp logpoller.LogPoller, eventQueries []EventQuery, limitAndSort query.LimitAndSort) (iter.Seq2[string, commontypes.Sequence], error) {

for _, eq := range eventQueries {
if err := eq.EventBinding.validateBound(eq.Address); err != nil {
return nil, newMultiEventTypeQueryError(eventQueries, err)
return nil, err
}
}

Expand Down Expand Up @@ -63,12 +72,12 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri

logs, err := lp.FilteredLogs(ctx, []query.Expression{eventQuery}, limitAndSort, queryName)
if err != nil {
return nil, newMultiEventTypeQueryError(eventQueries, wrapInternalErr(err))
return nil, wrapInternalErr(err)
}

seqIter, err := decodeMultiEventTypeLogsIntoSequences(ctx, logs, eventQueries)
if err != nil {
return nil, newMultiEventTypeQueryError(eventQueries, wrapInternalErr(err))
return nil, wrapInternalErr(err)
}

return seqIter, nil
Expand Down

0 comments on commit f6786cd

Please sign in to comment.