Skip to content

Commit

Permalink
fix: TimeManagerV5 remove function pointer and add conditional logic
Browse files Browse the repository at this point in the history
  • Loading branch information
0xlucian authored and chechu committed May 13, 2024
1 parent 9914060 commit d3b0ebf
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions contracts/TimeManagerV5.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ contract TimeManagerV5 {
/// @dev Sets true when contract is initialized
bool private isInitialized;

/**
* @dev Retrieves the current slot
* @return Current slot
*/
function() view returns (uint256) private _getCurrentSlot;
/// @notice Deprecated slot for _getCurrentSlot function pointer
bytes32 private __deprecatedSlot1;

/**
* @dev This empty reserved space is put in place to allow future versions to add new
Expand All @@ -32,7 +29,7 @@ contract TimeManagerV5 {
* @return Current block number or block timestamp
*/
function getBlockNumberOrTimestamp() public view returns (uint256) {
return _getCurrentSlot();
return isTimeBased ? _getBlockTimestamp() : _getBlockNumber();
}

/**
Expand All @@ -53,7 +50,6 @@ contract TimeManagerV5 {

isTimeBased = timeBased_;
blocksOrSecondsPerYear = timeBased_ ? SECONDS_PER_YEAR : blocksPerYear_;
_getCurrentSlot = timeBased_ ? _getBlockTimestamp : _getBlockNumber;
isInitialized = true;
}

Expand Down

0 comments on commit d3b0ebf

Please sign in to comment.