aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-12-12 09:31:16 +0800
committerGitHub <noreply@github.com>2018-12-12 09:31:16 +0800
commit5cff9110355f22a0887febe8728d445dc3867125 (patch)
tree6f07282c505ff2f37e20aa7a7285d757a5fecdcd
parentb3fa0c8dacb86e8e84ccad3451215402e1894cb9 (diff)
downloaddexon-sol-tools-5cff9110355f22a0887febe8728d445dc3867125.tar
dexon-sol-tools-5cff9110355f22a0887febe8728d445dc3867125.tar.gz
dexon-sol-tools-5cff9110355f22a0887febe8728d445dc3867125.tar.bz2
dexon-sol-tools-5cff9110355f22a0887febe8728d445dc3867125.tar.lz
dexon-sol-tools-5cff9110355f22a0887febe8728d445dc3867125.tar.xz
dexon-sol-tools-5cff9110355f22a0887febe8728d445dc3867125.tar.zst
dexon-sol-tools-5cff9110355f22a0887febe8728d445dc3867125.zip
Make pull_missing_blocks script consider all events with block numbers (#1420)
-rw-r--r--packages/pipeline/src/scripts/pull_missing_blocks.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/pipeline/src/scripts/pull_missing_blocks.ts b/packages/pipeline/src/scripts/pull_missing_blocks.ts
index 18fe1b700..275141a12 100644
--- a/packages/pipeline/src/scripts/pull_missing_blocks.ts
+++ b/packages/pipeline/src/scripts/pull_missing_blocks.ts
@@ -53,8 +53,21 @@ async function getAllMissingBlocks(web3Source: Web3Source): Promise<void> {
async function getMissingBlockNumbers(fromBlock: number): Promise<number[]> {
console.log(`Checking for missing blocks starting at ${fromBlock}...`);
+ // Note(albrow): The easiest way to get all the blocks we need is to
+ // consider all the events tables together in a single query. If this query
+ // gets too slow, we should consider re-architecting so that we can work on
+ // getting the blocks for one type of event at a time.
const response = (await connection.query(
- 'SELECT DISTINCT(block_number) FROM raw.exchange_fill_events WHERE block_number NOT IN (SELECT number FROM raw.blocks) AND block_number >= $1 ORDER BY block_number ASC LIMIT $2',
+ `WITH all_events AS (
+ SELECT block_number FROM raw.exchange_fill_events
+ UNION SELECT block_number FROM raw.exchange_cancel_events
+ UNION SELECT block_number FROM raw.exchange_cancel_up_to_events
+ UNION SELECT block_number FROM raw.erc20_approval_events
+ )
+ SELECT DISTINCT(block_number) FROM all_events
+ WHERE block_number NOT IN (SELECT number FROM raw.blocks)
+ AND block_number >= $1
+ ORDER BY block_number ASC LIMIT $2`,
[fromBlock, MAX_BLOCKS_PER_QUERY],
)) as MissingBlocksResponse[];
const blockNumberStrings = R.pluck('block_number', response);