diff --git a/blockchain-watcher/src/infrastructure/repositories/common/rateLimitedOptions.ts b/blockchain-watcher/src/infrastructure/repositories/common/rateLimitedOptions.ts new file mode 100644 index 00000000..57deba14 --- /dev/null +++ b/blockchain-watcher/src/infrastructure/repositories/common/rateLimitedOptions.ts @@ -0,0 +1,4 @@ +export type Options = { + period: number; + limit: number; +}; diff --git a/blockchain-watcher/src/infrastructure/repositories/evm/RateLimitedEvmJsonRPCBlockRepository.ts b/blockchain-watcher/src/infrastructure/repositories/evm/RateLimitedEvmJsonRPCBlockRepository.ts index 1b21e1c0..5519d1ef 100644 --- a/blockchain-watcher/src/infrastructure/repositories/evm/RateLimitedEvmJsonRPCBlockRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/evm/RateLimitedEvmJsonRPCBlockRepository.ts @@ -1,3 +1,7 @@ +import { Circuit, Ratelimit, Retry, RetryMode } from "mollitia"; +import { EvmBlockRepository } from "../../../domain/repositories"; +import { Options } from "../common/rateLimitedOptions"; +import winston from "../../log"; import { EvmBlock, EvmLogFilter, @@ -5,10 +9,6 @@ import { EvmTag, ReceiptTransaction, } from "../../../domain/entities"; -import { EvmBlockRepository } from "../../../domain/repositories"; -import winston from "../../log"; -import { Circuit, Ratelimit, Retry, RetryMode } from "mollitia"; -import { Options } from "../solana/RateLimitedSolanaSlotRepository"; export class RateLimitedEvmJsonRPCBlockRepository implements EvmBlockRepository { private delegate: EvmBlockRepository; @@ -31,7 +31,7 @@ export class RateLimitedEvmJsonRPCBlockRepository implements EvmBlockRepository factor: 1, onRejection: (err: Error | any) => { if (err.message?.startsWith("429 Too Many Requests")) { - this.logger.warn("Got 429 from solana RPC node. Retrying in 10 secs..."); + this.logger.warn("Got 429 from evm RPC node. Retrying in 10 secs..."); return 10_000; // Wait 10 secs if we get a 429 } else { return true; // Retry according to config diff --git a/blockchain-watcher/src/infrastructure/repositories/solana/RateLimitedSolanaSlotRepository.ts b/blockchain-watcher/src/infrastructure/repositories/solana/RateLimitedSolanaSlotRepository.ts index 14e42859..6736b89c 100644 --- a/blockchain-watcher/src/infrastructure/repositories/solana/RateLimitedSolanaSlotRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/solana/RateLimitedSolanaSlotRepository.ts @@ -3,6 +3,7 @@ import { solana } from "../../../domain/entities"; import { SolanaSlotRepository } from "../../../domain/repositories"; import { Fallible, SolanaFailure, ErrorType } from "../../../domain/errors"; import winston from "../../../infrastructure/log"; +import { Options } from "../common/rateLimitedOptions"; export class RateLimitedSolanaSlotRepository implements SolanaSlotRepository { private delegate: SolanaSlotRepository; @@ -85,8 +86,3 @@ export class RateLimitedSolanaSlotRepository implements SolanaSlotRepository { return this.breaker.fn(() => this.delegate.getTransactions(sigs, finality)).execute(); } } - -export type Options = { - period: number; - limit: number; -}; diff --git a/blockchain-watcher/src/infrastructure/repositories/sui/RateLimitedSuiJsonRPCBlockRepository.ts b/blockchain-watcher/src/infrastructure/repositories/sui/RateLimitedSuiJsonRPCBlockRepository.ts index ecc8743b..010428ae 100644 --- a/blockchain-watcher/src/infrastructure/repositories/sui/RateLimitedSuiJsonRPCBlockRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/sui/RateLimitedSuiJsonRPCBlockRepository.ts @@ -1,10 +1,10 @@ +import { Checkpoint, SuiEventFilter, TransactionFilter } from "@mysten/sui.js/client"; import { Circuit, Ratelimit, Retry, RetryMode } from "mollitia"; import { SuiTransactionBlockReceipt } from "../../../domain/entities/sui"; import { SuiRepository } from "../../../domain/repositories"; -import { Options } from "../solana/RateLimitedSolanaSlotRepository"; +import { Options } from "../common/rateLimitedOptions"; import { Range } from "../../../domain/entities"; import winston from "winston"; -import { Checkpoint, SuiEventFilter, TransactionFilter } from "@mysten/sui.js/client"; export class RateLimitedSuiJsonRPCBlockRepository implements SuiRepository { private delegate: SuiRepository; @@ -27,7 +27,7 @@ export class RateLimitedSuiJsonRPCBlockRepository implements SuiRepository { factor: 1, onRejection: (err: Error | any) => { if (err.message?.startsWith("429 Too Many Requests")) { - this.logger.warn("Got 429 from solana RPC node. Retrying in 10 secs..."); + this.logger.warn("Got 429 from sui RPC node. Retrying in 10 secs..."); return 10_000; // Wait 10 secs if we get a 429 } else { return true; // Retry according to config diff --git a/blockchain-watcher/src/infrastructure/rpc/http/InstrumentedHttpProvider.ts b/blockchain-watcher/src/infrastructure/rpc/http/InstrumentedHttpProvider.ts index 939452c3..c62de3bc 100644 --- a/blockchain-watcher/src/infrastructure/rpc/http/InstrumentedHttpProvider.ts +++ b/blockchain-watcher/src/infrastructure/rpc/http/InstrumentedHttpProvider.ts @@ -18,7 +18,7 @@ export class InstrumentedHttpProvider { private url: string; health: ProviderHealthInstrumentation; - private logger: winston.Logger = winston.child({ module: "RateLimitedSolanaSlotRepository" }); + private logger: winston.Logger = winston.child({ module: "InstrumentedHttpProvider" }); constructor(options: InstrumentedHttpProviderOptions) { options?.initialDelay && (this.initialDelay = options.initialDelay);