Skip to content

Commit 5578514

Browse files
AndresElizondoAndrés Elizondo
and
Andrés Elizondo
authored
Avoids edge case causing missing blocks due to backfilling blocks ahe… (#170)
* Avoids edge case causing missing blocks due to backfilling blocks ahead of the event scraper. * Prettier. * Upper case SQL. --------- Co-authored-by: Andrés Elizondo <[email protected]>
1 parent f067cde commit 5578514

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/config.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,10 @@ export const SCRAPER_MODE: ScraperMode =
146146
process.env.SCRAPER_MODE === undefined
147147
? DEFAULT_SCRAPER_MODE
148148
: process.env.SCRAPER_MODE === 'BLOCKS'
149-
? 'BLOCKS'
150-
: process.env.SCRAPER_MODE === 'EVENTS'
151-
? 'EVENTS'
152-
: throwError('Wrong SCRAPER_MODE');
149+
? 'BLOCKS'
150+
: process.env.SCRAPER_MODE === 'EVENTS'
151+
? 'EVENTS'
152+
: throwError('Wrong SCRAPER_MODE');
153153
export const METRICS_PATH = process.env.METRICS_PATH || DEFAULT_METRICS_PATH;
154154

155155
export const PROMETHEUS_PORT = getIntConfig('PROMETHEUS_PORT', DEFAULT_PROMETHEUS_PORT);
@@ -390,13 +390,13 @@ export const FEAT_UNISWAP_V2_PAIR_CREATED_EVENT = getBoolConfig(
390390
export const UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS = process.env
391391
.UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS
392392
? process.env.UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS.split(',').map((contract) => {
393-
const [name, factoryAddress, startBlock] = contract.split(':');
394-
return {
395-
name,
396-
factoryAddress,
397-
startBlock: parseInt(startBlock),
398-
};
399-
})
393+
const [name, factoryAddress, startBlock] = contract.split(':');
394+
return {
395+
name,
396+
factoryAddress,
397+
startBlock: parseInt(startBlock),
398+
};
399+
})
400400
: [];
401401

402402
if (

src/scripts/pull_and_save_block_events.ts

+1
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ export class BlockEventsScraper {
363363
`SELECT DISTINCT block_number
364364
FROM ${SCHEMA}.tx_backfill
365365
WHERE done = false
366+
AND block_number < (SELECT MAX(block_number) FROM ${SCHEMA}.blocks)
366367
ORDER BY block_number
367368
LIMIT ${MAX_BLOCKS_TO_PULL}`,
368369
);

0 commit comments

Comments
 (0)