Skip to content

Commit

Permalink
Post review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-sekara committed Aug 21, 2024
1 parent 027a65e commit 0cb98b5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/services/ccip/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"fmt"
"time"

mapset "github.com/deckarep/golang-set/v2"

"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/assets"
Expand Down Expand Up @@ -155,6 +153,8 @@ func (o *orm) pickOnlyRelevantTokensForUpdate(
) ([]TokenPrice, error) {
tokenPricesByAddress := toTokensByAddress(tokenPrices)

// Picks only tokens which were recently updated and can be ignored,
// we will filter out these tokens from the upsert query.
stmt := `
SELECT
token_addr
Expand All @@ -172,11 +172,15 @@ func (o *orm) pickOnlyRelevantTokensForUpdate(
return nil, err
}

tokensToIgnore := mapset.NewThreadUnsafeSet[string](dbTokensToIgnore...)
tokensToIgnore := make(map[string]struct{}, len(dbTokensToIgnore))
for _, tk := range dbTokensToIgnore {
tokensToIgnore[tk] = struct{}{}
}

tokenPricesToUpdate := make([]TokenPrice, 0, len(tokenPrices))
for tokenAddr, tokenPrice := range tokenPricesByAddress {
eligibleForUpdate := false
if !tokensToIgnore.Contains(tokenAddr) {
if _, ok := tokensToIgnore[tokenAddr]; !ok {
eligibleForUpdate = true
tokenPricesToUpdate = append(tokenPricesToUpdate, TokenPrice{TokenAddr: tokenAddr, TokenPrice: tokenPrice})
}
Expand Down

0 comments on commit 0cb98b5

Please sign in to comment.