Skip to content

Commit

Permalink
Refactor blockRangesAreInvalid to internal helper func
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Dec 5, 2024
1 parent 1b6da03 commit a638412
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/dataworker/Dataworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class Dataworker {

// Exit early if spoke pool clients don't have early enough event data to satisfy block ranges for the
// potential proposal
const blockRangesAreInvalid = await blockRangesAreInvalidForSpokeClients(
const blockRangesAreInvalid = await this._validateBlockRanges(
spokePoolClients,
blockRangesForProposal,
chainIds,
Expand Down Expand Up @@ -833,7 +833,7 @@ export class Dataworker {

// Exit early if spoke pool clients don't have early enough event data to satisfy block ranges for the
// pending proposal. Log an error loudly so that user knows that disputer needs to increase its lookback.
const blockRangesAreInvalid = await blockRangesAreInvalidForSpokeClients(
const blockRangesAreInvalid = await this._validateBlockRanges(
spokePoolClients,
blockRangesImpliedByBundleEndBlocks,
chainIds,
Expand Down Expand Up @@ -1067,7 +1067,7 @@ export class Dataworker {
);
const mainnetBlockRange = blockNumberRanges[0];
const chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(mainnetBlockRange[0]);
const blockRangesAreInvalid = await blockRangesAreInvalidForSpokeClients(
const blockRangesAreInvalid = await this._validateBlockRanges(
spokePoolClients,
blockNumberRanges,
chainIds,
Expand Down Expand Up @@ -2022,7 +2022,7 @@ export class Dataworker {
const blockNumberRanges = getImpliedBundleBlockRanges(hubPoolClient, configStoreClient, matchingRootBundle);
const mainnetBlockRanges = blockNumberRanges[0];
const chainIds = this.clients.configStoreClient.getChainIdIndicesForBlock(mainnetBlockRanges[0]);
const blockRangesAreInvalid = await blockRangesAreInvalidForSpokeClients(
const blockRangesAreInvalid = await this._validateBlockRanges(
spokePoolClients,
blockNumberRanges,
chainIds,
Expand Down Expand Up @@ -2445,4 +2445,20 @@ export class Dataworker {
this.clients.configStoreClient.getEnabledChains(mainnetBundleStartBlock)
);
}

async _validateBlockRanges(
spokePoolClients: SpokePoolClientsByChain,
blockRanges: number[][],
chainIds: number[],
earliestBlocksInSpokePoolClients: { [chainId: number]: number },
isV3: boolean
): Promise<ReturnType<typeof blockRangesAreInvalidForSpokeClients>> {
return await blockRangesAreInvalidForSpokeClients(
spokePoolClients,
blockRanges,
chainIds,
earliestBlocksInSpokePoolClients,
isV3
);
}
}

0 comments on commit a638412

Please sign in to comment.