Fix lookup documentation in ERC20Votes and Checkpoints (#4218)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
This commit is contained in:
ToonVanHove
2023-05-05 22:25:23 +02:00
committed by GitHub
parent 72ed4ca67a
commit 692d8c85a4
3 changed files with 18 additions and 18 deletions

View File

@ -114,7 +114,7 @@ abstract contract ERC20Votes is ERC20Permit, IERC5805 {
* @dev Lookup a value in a list of (sorted) checkpoints.
*/
function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 timepoint) private view returns (uint256) {
// We run a binary search to look for the earliest checkpoint taken after `timepoint`.
// We run a binary search to look for the last (most recent) checkpoint taken before (or at) `timepoint`.
//
// Initially we check if the block is recent to narrow the search range.
// During the loop, the index of the wanted checkpoint remains in the range [low-1, high).