From 0c8546d4741189a6b8c909347fab3f09a81b2365 Mon Sep 17 00:00:00 2001 From: Matthew Pendrey Date: Tue, 26 Nov 2024 10:24:24 +0000 Subject: [PATCH] lint --- .../services/relay/evm/read/multieventtype.go | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/services/relay/evm/read/multieventtype.go b/core/services/relay/evm/read/multieventtype.go index f3416239289..388805cae98 100644 --- a/core/services/relay/evm/read/multieventtype.go +++ b/core/services/relay/evm/read/multieventtype.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "reflect" + "strconv" "strings" "github.com/ethereum/go-ethereum/common" @@ -36,7 +37,7 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri ReturnVal: eq.SequenceDataType, }, "", eventReadType) } else { - err = fmt.Errorf("no event queries provided: %v", err) + err = fmt.Errorf("no event queries provided: %w", err) } } }() @@ -47,8 +48,8 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri } } - var allFilterExpressions []query.Expression - for _, eq := range eventQueries { + allFilterExpressions := make([]query.Expression, 0, len(eventQueries)) + for idx, eq := range eventQueries { var expressions []query.Expression defaultExpressions := []query.Expression{ @@ -57,15 +58,15 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri } expressions = append(expressions, defaultExpressions...) - remapped, err := eq.EventBinding.remap(eq.Filter) - if err != nil { - return nil, fmt.Errorf("error remapping filter: %v", err) + remapped, remapErr := eq.EventBinding.remap(eq.Filter) + if remapErr != nil { + return nil, fmt.Errorf("error remapping filter: %w", err) } expressions = append(expressions, remapped.Expressions...) filterExpression := query.And(expressions...) - allFilterExpressions = append(allFilterExpressions, filterExpression) + allFilterExpressions[idx] = filterExpression } eventQuery := query.Or(allFilterExpressions...) @@ -74,7 +75,7 @@ func MultiEventTypeQuery(ctx context.Context, lp logpoller.LogPoller, eventQueri for _, eq := range eventQueries { queryName += eq.EventBinding.contractName + "-" + eq.Address.String() + "-" + eq.EventBinding.eventName + "-" } - strings.TrimSuffix(queryName, "-") + queryName = strings.TrimSuffix(queryName, "-") logs, err := lp.FilteredLogs(ctx, []query.Expression{eventQuery}, limitAndSort, queryName) if err != nil { @@ -116,9 +117,9 @@ func decodeMultiEventTypeLogsIntoSequences(ctx context.Context, logs []logpoller Sequence: commontypes.Sequence{ Cursor: logpoller.FormatContractReaderCursor(logEntry), Head: commontypes.Head{ - Height: fmt.Sprint(logEntry.BlockNumber), + Height: strconv.FormatInt(logEntry.BlockNumber, 10), Hash: logEntry.BlockHash.Bytes(), - Timestamp: uint64(logEntry.BlockTimestamp.Unix()), + Timestamp: uint64(logEntry.BlockTimestamp.Unix()), //nolint:gosec // G115 false positive }, }, }