From f6884b9cda33bd7185bfc779c32b68b840e53098 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Mon, 9 Sep 2024 16:50:19 +0530 Subject: [PATCH 1/2] chore: avoid duplicate write --- src/prices/provider.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/prices/provider.ts b/src/prices/provider.ts index 01f75656..a8d48091 100644 --- a/src/prices/provider.ts +++ b/src/prices/provider.ts @@ -211,10 +211,19 @@ export function createPriceProvider( }); } - await db.applyChange({ - type: "InsertManyPrices", - prices: [newPrice], - }); + // Check if the price is already in the database + const existingPrice = await db.getTokenPriceByBlockNumber( + chainId, + newPrice.tokenAddress, + blockNumber + ); + + if (!existingPrice) { + await db.applyChange({ + type: "InsertManyPrices", + prices: [newPrice], + }); + } return { ...newPrice, tokenDecimals: token.decimals }; } From c49276d2c692194b180eff53ce2b77d8558cb814 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Mon, 9 Sep 2024 16:54:02 +0530 Subject: [PATCH 2/2] cleanup --- src/config.ts | 2 +- src/index.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/config.ts b/src/config.ts index 1d156e1b..e78f8e0f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1489,7 +1489,7 @@ const CHAINS: Chain[] = [ .default("https://evm-rpc.sei-apis.com") .parse(process.env.SEI_MAINNET_RPC_URL), pricesFromTimestamp: Date.UTC(2024, 0, 1, 0, 0, 0), - maxGetLogsRange: 1000, + maxGetLogsRange: 10000, tokens: [ { code: "SEI", diff --git a/src/index.ts b/src/index.ts index 4e749fe1..17b11252 100644 --- a/src/index.ts +++ b/src/index.ts @@ -526,13 +526,13 @@ async function catchupAndWatchChain( // Iterate through each gateway and attempt to fetch data for (const gateway of config.ipfsGateways) { const url = `${gateway}/ipfs/${cid}`; - chainLogger.info(`Trying IPFS gateway: ${gateway} for CID: ${cid}`); + // chainLogger.info(`Trying IPFS gateway: ${gateway} for CID: ${cid}`); const result = await fetchFromGateway(url); if (result !== undefined) { - chainLogger.info( - `Fetch successful from gateway: ${gateway} for CID: ${cid}` - ); + // chainLogger.info( + // `Fetch successful from gateway: ${gateway} for CID: ${cid}` + // ); // Save to IpfsData table try {