Feature suggestion: `blockAtTimestamp`
- Dominant language
- Python
- Stars
- 5.5k
- Forks
- 1.7k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 2
Description
### Motivation
It is sometimes useful to find the closest block to a given timestamp for searching purposes. It is not easy to do so as there is no RPC method to call to do so, with the most efficient method probably being a binary search assuming an average delay between blocks.
### Specification
After input validation (timestamp not in the future or before chain genesis), estimate the number of blocks behind tip to start a binary search in order to find the latest block prior (or including) the given timestamp. Make sure to convert timestamps correctly to UTC as they can be localized. It should be possible to identify the correct block via 3-5 iterations of this algorithm, making that many calls to `getBlock()` to obtain the answer.
Contributor guide
Assessment
This issue has not been assessed yet.