Commit 27e4077e authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #1389 from TransmissionsDev/patch-2

Watcher: Make blocks to fetch a config option
parents 9c99393f 2aa4416e
---
"@eth-optimism/core-utils": patch
---
Watcher: Make blocks to fetch a config option
......@@ -11,13 +11,14 @@ export interface WatcherOptions {
l1: Layer
l2: Layer
pollInterval?: number
blocksToFetch?: number
}
export class Watcher {
public l1: Layer
public l2: Layer
public pollInterval = 3000
public NUM_BLOCKS_TO_FETCH = 9_999
public blocksToFetch = 2000
constructor(opts: WatcherOptions) {
this.l1 = opts.l1
......@@ -25,6 +26,9 @@ export class Watcher {
if (opts.pollInterval) {
this.pollInterval = opts.pollInterval
}
if (opts.blocksToFetch) {
this.blocksToFetch = opts.blocksToFetch
}
}
public async getMessageHashesFromL1Tx(l1TxHash: string): Promise<string[]> {
......@@ -83,7 +87,7 @@ export class Watcher {
// scan for transaction with specified message
while (matches.length === 0) {
const blockNumber = await layer.provider.getBlockNumber()
const startingBlock = Math.max(blockNumber - this.NUM_BLOCKS_TO_FETCH, 0)
const startingBlock = Math.max(blockNumber - this.blocksToFetch, 0)
const successFilter: ethers.providers.Filter = {
address: layer.messengerAddress,
topics: [ethers.utils.id(`RelayedMessage(bytes32)`)],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment