From 1c1e3d990b0cad3d7b1ab07f076290d754200dc4 Mon Sep 17 00:00:00 2001 From: 0xroll <96259407+0xroll@users.noreply.github.com> Date: Sat, 2 Nov 2024 19:29:07 +0800 Subject: [PATCH] Revert "[stargate] add delay between calls" --- adapters/stargate/hourly_blocks.csv | 3 +-- adapters/stargate/src/index.ts | 20 ++++++++++---------- adapters/stargate/src/sdk/config.ts | 2 +- adapters/stargate/src/sdk/lib.ts | 2 -- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/adapters/stargate/hourly_blocks.csv b/adapters/stargate/hourly_blocks.csv index 72d296b1..cc795db9 100644 --- a/adapters/stargate/hourly_blocks.csv +++ b/adapters/stargate/hourly_blocks.csv @@ -1,3 +1,2 @@ number,timestamp -11535322,1717513197 -11537120,1730541599 \ No newline at end of file +5154879,1717513197 \ No newline at end of file diff --git a/adapters/stargate/src/index.ts b/adapters/stargate/src/index.ts index abff785c..51d95ea1 100644 --- a/adapters/stargate/src/index.ts +++ b/adapters/stargate/src/index.ts @@ -36,16 +36,16 @@ const readBlocksFromCSV = async (filePath: string): Promise => { readBlocksFromCSV(path.resolve(__dirname, "../hourly_blocks.csv")) .then(async (blocks) => { - for (const block of blocks) { - // Sequentially process each stream for the block - const v2Stream = new PositionsStream(block, POSITIONS_V2_SUBGRAPH_URL); - const v1Stream = new PositionsStream(block, POSITIONS_V1_SUBGRAPH_URL); - await mergeStreams([v1Stream, v2Stream]); - } -}) -.catch((err) => { - console.error("Error reading CSV file:", err); -}); + const streams = blocks.flatMap((block) => [ + new PositionsStream(block, POSITIONS_V1_SUBGRAPH_URL), + new PositionsStream(block, POSITIONS_V2_SUBGRAPH_URL), + ]); + + mergeStreams(streams); + }) + .catch((err) => { + console.error("Error reading CSV file:", err); + }); function mergeStreams(positionStreams: PositionsStream[]) { const csvWriteStream = fs.createWriteStream(`outputData.csv`, { diff --git a/adapters/stargate/src/sdk/config.ts b/adapters/stargate/src/sdk/config.ts index 78c44ed4..1578e272 100644 --- a/adapters/stargate/src/sdk/config.ts +++ b/adapters/stargate/src/sdk/config.ts @@ -8,7 +8,7 @@ export const POSITIONS_V2_SUBGRAPH_URL = export const client = createPublicClient({ chain: linea, - transport: http(`https://rpc.linea.build`, { + transport: http(`https://linea-mainnet.infura.io/v3/${process.env.OPENBLOCK_LINEA_INFURA_API_KEY}`, { retryCount: 5, timeout: 60_000, }), diff --git a/adapters/stargate/src/sdk/lib.ts b/adapters/stargate/src/sdk/lib.ts index 14bd1f8a..b7b370d2 100644 --- a/adapters/stargate/src/sdk/lib.ts +++ b/adapters/stargate/src/sdk/lib.ts @@ -3,7 +3,6 @@ import { client } from "./config"; import { Position } from "./types"; const WHITELISTED_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"; -const FETCH_DELAY_MS = 5000 export const getTimestampAtBlock = async (blockNumber: number) => { const block = await client.getBlock({ @@ -24,7 +23,6 @@ export class PositionsStream extends Readable { } async _read() { - await new Promise(resolve => setTimeout(resolve, FETCH_DELAY_MS)); const query = ` query { farmPositions(