Skip to content

Commit

Permalink
Fix DMDcoin#48: Adjust phase duration calculation to prevent shorteni…
Browse files Browse the repository at this point in the history
…ng on delayed switchPhase calls
  • Loading branch information
MSalman6 committed Jan 22, 2025
1 parent 7639040 commit f48fb7e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions contracts/DiamondDao.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,16 @@ contract DiamondDao is IDiamondDao, Initializable, ReentrancyGuardUpgradeable, V
}

function switchPhase() external nonReentrant {
if (block.timestamp < daoPhase.end) {
uint64 currentTimestamp = uint64(block.timestamp);

if (currentTimestamp < daoPhase.end) {
return;
}

Phase newPhase = daoPhase.phase == Phase.Proposal ? Phase.Voting : Phase.Proposal;

uint64 newPhaseStart = daoPhase.end + 1;
daoPhase.start = newPhaseStart;
daoPhase.end = newPhaseStart + DAO_PHASE_DURATION;
daoPhase.start = currentTimestamp;
daoPhase.end = currentTimestamp + DAO_PHASE_DURATION;
daoPhase.phase = newPhase;

ProposalState stateToSet = newPhase == Phase.Voting
Expand Down

0 comments on commit f48fb7e

Please sign in to comment.