{
    "Function": "_checkpointsLookup",
    "File": "contracts/openzeppelin-solidity/contracts/token/ERC20/extensions/ERC20Votes.sol",
    "Parent Contracts": [
        "contracts/openzeppelin-solidity/contracts/token/ERC20/extensions/draft-ERC20Permit.sol",
        "contracts/openzeppelin-solidity/contracts/utils/cryptography/draft-EIP712.sol",
        "contracts/openzeppelin-solidity/contracts/token/ERC20/extensions/draft-IERC20Permit.sol",
        "contracts/openzeppelin-solidity/contracts/token/ERC20/ERC20.sol",
        "contracts/openzeppelin-solidity/contracts/token/ERC20/extensions/IERC20Metadata.sol",
        "contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol",
        "contracts/openzeppelin-solidity/contracts/utils/Context.sol",
        "contracts/openzeppelin-solidity/contracts/governance/utils/IVotes.sol"
    ],
    "High-Level Calls": [
        "Math"
    ],
    "Internal Calls": [],
    "Library Calls": [
        "average"
    ],
    "Low-Level Calls": [],
    "Code": "function _checkpointsLookup(Checkpoint[] storage ckpts, uint256 blockNumber) private view returns (uint256) {\n        // We run a binary search to look for the earliest checkpoint taken after `blockNumber`.\n        //\n        // During the loop, the index of the wanted checkpoint remains in the range [low-1, high).\n        // With each iteration, either `low` or `high` is moved towards the middle of the range to maintain the invariant.\n        // - If the middle checkpoint is after `blockNumber`, we look in [low, mid)\n        // - If the middle checkpoint is before or equal to `blockNumber`, we look in [mid+1, high)\n        // Once we reach a single value (when low == high), we've found the right checkpoint at the index high-1, if not\n        // out of bounds (in which case we're looking too far in the past and the result is 0).\n        // Note that if the latest checkpoint available is exactly for `blockNumber`, we end up with an index that is\n        // past the end of the array, so we technically don't find a checkpoint after `blockNumber`, but it works out\n        // the same.\n        uint256 high = ckpts.length;\n        uint256 low = 0;\n        while (low < high) {\n            uint256 mid = Math.average(low, high);\n            if (ckpts[mid].fromBlock > blockNumber) {\n                high = mid;\n            } else {\n                low = mid + 1;\n            }\n        }\n\n        return high == 0 ? 0 : ckpts[high - 1].votes;\n    }"
}