Skip to content

Commit

Permalink
Fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
winder committed Apr 1, 2024
1 parent f28263e commit b7709d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func testMonitoring(t *testing.T, name string, server *httptest.Server, requests
usdcTokenAddr := utils.RandomAddress()
observedHttpClient := http2.NewObservedIHttpClientWithMetric(&http2.HttpClient{}, histogram)
tokenDataReaderDefault := usdc.NewUSDCTokenDataReader(log, usdcReader, attestationURI, 0, usdcTokenAddr, 0)
tokenDataReader := usdc.NewUSDCTokenDataReaderWithHttpClient(*tokenDataReaderDefault, observedHttpClient, usdcTokenAddr)
tokenDataReader := usdc.NewUSDCTokenDataReaderWithHttpClient(*tokenDataReaderDefault, observedHttpClient, usdcTokenAddr, 0)
require.NotNil(t, tokenDataReader)

for i := 0; i < requests; i++ {
Expand Down
4 changes: 3 additions & 1 deletion core/services/ocr2/plugins/ccip/tokendata/usdc/usdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ func NewUSDCTokenDataReaderWithHttpClient(
origin TokenDataReader,
httpClient http.IHttpClient,
usdcTokenAddress common.Address,
requestInterval time.Duration,
) *TokenDataReader {
return &TokenDataReader{
lggr: origin.lggr,
Expand All @@ -140,6 +141,7 @@ func NewUSDCTokenDataReaderWithHttpClient(
attestationApiTimeout: origin.attestationApiTimeout,
coolDownMu: origin.coolDownMu,
usdcTokenAddress: usdcTokenAddress,
rate: rate.NewLimiter(rate.Every(requestInterval), 1),
}
}

Expand All @@ -154,7 +156,7 @@ func (s *TokenDataReader) ReadTokenData(ctx context.Context, msg cciptypes.EVM2E
}

// Using 'Allow' instead of 'Wait' to avoid blocking the current goroutine.
if !s.rate.Allow() {
if s.rate != nil && !s.rate.Allow() {
// self rate limiting to avoid hitting the rate limit.
return nil, tokendata.ErrSelfRateLimit
}
Expand Down

0 comments on commit b7709d7

Please sign in to comment.