Skip to content

Commit

Permalink
improve(utils): Avoid recomputing relayData hashes
Browse files Browse the repository at this point in the history
This will save redundant recomputation cycles of a relayData hash when
it is needed more than once.
  • Loading branch information
pxrl committed May 31, 2024
1 parent 25c5cd7 commit 9ac70d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/interfaces/SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface RelayData {
fillDeadline: number;
exclusiveRelayer: string;
exclusivityDeadline: number;
_hash?: Record<number, string>;
}

export interface Deposit extends RelayData {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/SpokeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ export async function getDepositIdAtBlock(contract: Contract, blockTag: number):
* @returns The corresponding RelayData hash.
*/
export function getRelayDataHash(relayData: RelayData, destinationChainId: number): string {
return ethersUtils.keccak256(
relayData._hash ??= {};

return relayData._hash[destinationChainId] ??= ethersUtils.keccak256(

Check warning on line 221 in src/utils/SpokeUtils.ts

View workflow job for this annotation

GitHub Actions / Lint

Insert `(`
ethersUtils.defaultAbiCoder.encode(
[
"tuple(" +
Expand Down

0 comments on commit 9ac70d0

Please sign in to comment.