Skip to content

Commit b7caf54

Browse files
committed
Parameterize MAX_ALLOWANCE in Clock lib
1 parent 6cf08d6 commit b7caf54

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

prt/contracts/src/tournament/abstracts/Tournament.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ abstract contract Tournament {
357357
Clock.State storage _firstClock = clocks[_danglingCommitment];
358358

359359
// grant extra match effort for both clocks
360-
_firstClock.addMatchEffort(matchEffort);
361-
_newClock.addMatchEffort(matchEffort);
360+
_firstClock.addMatchEffort(matchEffort, maxAllowance);
361+
_newClock.addMatchEffort(matchEffort, maxAllowance);
362362

363363
_firstClock.advanceClock();
364364

prt/contracts/src/tournament/libs/Clock.sol

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,15 @@ library Clock {
128128
}
129129

130130
/// @notice Add matchEffort to a clock and set it to paused.
131-
/// The new clock allowance is capped by `MAX_ALLOWANCE`.
132-
function addMatchEffort(State storage state, Time.Duration matchEffort)
133-
internal
134-
{
131+
/// The new clock allowance is capped by maxAllowance.
132+
function addMatchEffort(
133+
State storage state,
134+
Time.Duration matchEffort,
135+
Time.Duration maxAllowance
136+
) internal {
135137
Time.Duration _timeLeft = timeLeft(state);
136138

137-
Time.Duration _allowance = _timeLeft.add(matchEffort);
138-
139-
if (_allowance.gt(ArbitrationConstants.MAX_ALLOWANCE)) {
140-
_allowance = ArbitrationConstants.MAX_ALLOWANCE;
141-
}
139+
Time.Duration _allowance = _timeLeft.add(matchEffort).min(maxAllowance);
142140

143141
_setNewPaused(state, _allowance);
144142
}

0 commit comments

Comments
 (0)