PR #2: allow setting sync interval for blocks #26

Merged
Theo merged 3 commits from :master into master 2023-07-14 21:09:37 +03:00
2 changed files with 3 additions and 2 deletions
Showing only changes of commit 02f79a0de0 - Show all commits

View File

@ -1,3 +1,4 @@
export const blockSyncInterval = 10000
export const enabledChains = ['1', '10', '56', '100', '137', '42161']
export const chainsWithEncryptedNotes = ['1', '5', '56', '100', '137']
export default {

View File

@ -2,7 +2,7 @@ import fs from 'fs'
import zlib from 'zlib'
import Web3 from 'web3'
import networkConfig from '../../networkConfig'
import networkConfig, { blockSyncInterval } from '../../networkConfig'
export function download({ name, directory }) {
const path = `${directory}${name}.gz`.toLowerCase()
@ -53,7 +53,7 @@ export async function getPastEvents({ type, fromBlock, netId, events, contractAt
const blockDifference = Math.ceil(blockNumberBuffer - fromBlock)
// eth_logs and eth_filter are restricted > 10,000 block queries
const blockRange = 10000
const blockRange = blockSyncInterval ? blockSyncInterval : 10_000
let chunksCount = blockDifference === 0 ? 1 : Math.ceil(blockDifference / blockRange)
const chunkSize = Math.ceil(blockDifference / chunksCount)