Skip to content

Commit da5cf42

Browse files
authored
perf: refactor to modifers to use internal functions (#272)
1 parent b45dced commit da5cf42

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/RegistryCoordinator.sol

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,14 @@ contract RegistryCoordinator is
4242
using BN254 for BN254.G1Point;
4343

4444
modifier onlyEjector {
45-
require(msg.sender == ejector, "RegistryCoordinator.onlyEjector: caller is not the ejector");
45+
_checkEjector();
4646
_;
4747
}
4848

4949
/// @dev Checks that `quorumNumber` corresponds to a quorum that has been created
5050
/// via `initialize` or `createQuorum`
5151
modifier quorumExists(uint8 quorumNumber) {
52-
require(
53-
quorumNumber < quorumCount,
54-
"RegistryCoordinator.quorumExists: quorum does not exist"
55-
);
52+
_checkQuorumExists(quorumNumber);
5653
_;
5754
}
5855

@@ -517,6 +514,26 @@ contract RegistryCoordinator is
517514
return results;
518515
}
519516

517+
/**
518+
* @notice Checks if the caller is the ejector
519+
* @dev Reverts if the caller is not the ejector
520+
*/
521+
function _checkEjector() internal view {
522+
require(msg.sender == ejector, "RegistryCoordinator.onlyEjector: caller is not the ejector");
523+
}
524+
525+
/**
526+
* @notice Checks if a quorum exists
527+
* @param quorumNumber The quorum number to check
528+
* @dev Reverts if the quorum does not exist
529+
*/
530+
function _checkQuorumExists(uint8 quorumNumber) internal view {
531+
require(
532+
quorumNumber < quorumCount,
533+
"RegistryCoordinator.quorumExists: quorum does not exist"
534+
);
535+
}
536+
520537
/**
521538
* @notice Fetches an operator's pubkey hash from the BLSApkRegistry. If the
522539
* operator has not registered a pubkey, attempts to register a pubkey using

0 commit comments

Comments
 (0)