Skip to content

Commit

Permalink
add same structure for root cache
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Rice <[email protected]>
  • Loading branch information
mrice32 committed Mar 22, 2024
1 parent a20e637 commit f839278
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dataworker/Dataworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export type PoolRebalanceRoot = {
tree: MerkleTree<PoolRebalanceLeaf>;
};

type PoolRebalanceRootCache = Record<string, PoolRebalanceRoot>;
type PoolRebalanceRootCache = Record<string, Promise<PoolRebalanceRoot>>;

// @notice Constructs roots to submit to HubPool on L1. Fetches all data synchronously from SpokePool/HubPool clients
// so this class assumes that those upstream clients are already updated and have fetched on-chain data from RPC's.
Expand Down Expand Up @@ -2275,7 +2275,7 @@ export class Dataworker {
// executor running for tonight (2023-08-28) until we can fix the
// root cache rebalancing bug.
if (!this.rootCache[key] || process.env.DATAWORKER_DISABLE_REBALANCE_ROOT_CACHE === "true") {
this.rootCache[key] = await _buildPoolRebalanceRoot(
this.rootCache[key] = _buildPoolRebalanceRoot(
latestMainnetBlock,
mainnetBundleEndBlock,
fillsToRefund,
Expand All @@ -2296,7 +2296,7 @@ export class Dataworker {
);
}

return _.cloneDeep(this.rootCache[key]);
return _.cloneDeep(await this.rootCache[key]);
}

_getRequiredEthForArbitrumPoolRebalanceLeaf(leaf: PoolRebalanceLeaf): BigNumber {
Expand Down

0 comments on commit f839278

Please sign in to comment.