Skip to content

Commit

Permalink
perf: refactor to modifers to use internal functions (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevennevins authored Jun 14, 2024
1 parent b45dced commit da5cf42
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/RegistryCoordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ contract RegistryCoordinator is
using BN254 for BN254.G1Point;

modifier onlyEjector {
require(msg.sender == ejector, "RegistryCoordinator.onlyEjector: caller is not the ejector");
_checkEjector();
_;
}

/// @dev Checks that `quorumNumber` corresponds to a quorum that has been created
/// via `initialize` or `createQuorum`
modifier quorumExists(uint8 quorumNumber) {
require(
quorumNumber < quorumCount,
"RegistryCoordinator.quorumExists: quorum does not exist"
);
_checkQuorumExists(quorumNumber);
_;
}

Expand Down Expand Up @@ -517,6 +514,26 @@ contract RegistryCoordinator is
return results;
}

/**
* @notice Checks if the caller is the ejector
* @dev Reverts if the caller is not the ejector
*/
function _checkEjector() internal view {
require(msg.sender == ejector, "RegistryCoordinator.onlyEjector: caller is not the ejector");
}

/**
* @notice Checks if a quorum exists
* @param quorumNumber The quorum number to check
* @dev Reverts if the quorum does not exist
*/
function _checkQuorumExists(uint8 quorumNumber) internal view {
require(
quorumNumber < quorumCount,
"RegistryCoordinator.quorumExists: quorum does not exist"
);
}

/**
* @notice Fetches an operator's pubkey hash from the BLSApkRegistry. If the
* operator has not registered a pubkey, attempts to register a pubkey using
Expand Down

0 comments on commit da5cf42

Please sign in to comment.