-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve(BlockUtils): Simplify getBlockForTimestamp() (#791)
Two improvements here: - Remove the need to supply the HubPool chain ID to this function. I've been unable to find any other places in the code where the HubPool chain ID block numbers are accessed via the key `block_number_<timestamp>`, so just normalise all keys to be `<chainId>_block_number_<timestamp>`. This frees the caller from having to know what the HubPool chainId is. - Remove the need to supply the externally-supplied `currentChainTime`. This argument was _always_ supplied with the output of `getCurrentTime()`, which is not necessarily the current chain time anyway, and goes against the naming of the variable `currentTimeTime`. Instead, use the timestamp of the latest block to determine whether it's old enough to be cached. As background, the motivation for this change is that the Relayer now needs to apply its "max lookback" on RefundRequest events as well, so we have a common need for resolving timestamps to a previous block number. Simplifying getBlockForTimestamp() allows us to benefit from the caching that it implements.
- Loading branch information
Showing
5 changed files
with
20 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters