mirror of https://github.com/nucypher/nucypher.git
Some comments and require messages.
parent
2156a72866
commit
e795cf5cde
|
@ -162,9 +162,10 @@ contract MinersEscrow is Issuer {
|
||||||
* @notice Set mining adjudicator address
|
* @notice Set mining adjudicator address
|
||||||
**/
|
**/
|
||||||
function setMiningAdjudicator(MiningAdjudicatorInterface _miningAdjudicator) external onlyOwner {
|
function setMiningAdjudicator(MiningAdjudicatorInterface _miningAdjudicator) external onlyOwner {
|
||||||
require(address(miningAdjudicator) == address(0) &&
|
// Three-part require...
|
||||||
address(_miningAdjudicator) != address(0) &&
|
require(address(miningAdjudicator) == address(0) && // Can't adjudicator once it is set.
|
||||||
_miningAdjudicator.escrow() == address(this));
|
address(_miningAdjudicator) != address(0) && // Check to make sure that we're setting it somewhere.
|
||||||
|
_miningAdjudicator.escrow() == address(this)); // This is the escrow for the new adjudicator.
|
||||||
miningAdjudicator = _miningAdjudicator;
|
miningAdjudicator = _miningAdjudicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,9 @@ contract MiningAdjudicator is Upgradeable {
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
require(address(_escrow) != address(0) &&
|
// Sanity checks.
|
||||||
|
require(address(_escrow) != address(0) && // This contract has an escrow, and it's not the null address.
|
||||||
|
// The reward and penalty coefficients are set.
|
||||||
_percentagePenaltyCoefficient != 0 &&
|
_percentagePenaltyCoefficient != 0 &&
|
||||||
_rewardCoefficient != 0);
|
_rewardCoefficient != 0);
|
||||||
escrow = _escrow;
|
escrow = _escrow;
|
||||||
|
@ -98,12 +100,13 @@ contract MiningAdjudicator is Upgradeable {
|
||||||
)
|
)
|
||||||
public
|
public
|
||||||
{
|
{
|
||||||
require(_minerPublicKey.length == 65 && _requesterPublicKey.length == 65);
|
require(_minerPublicKey.length == 65 && _requesterPublicKey.length == 65,
|
||||||
|
"Either the requester or miner had an incorrect key length (ie, not 65)");
|
||||||
|
|
||||||
// Check that CFrag is not evaluated yet
|
// Check that CFrag is not evaluated yet
|
||||||
bytes32 evaluationHash = SignatureVerifier.hash(
|
bytes32 evaluationHash = SignatureVerifier.hash(
|
||||||
abi.encodePacked(_capsuleBytes, _cFragBytes), hashAlgorithm);
|
abi.encodePacked(_capsuleBytes, _cFragBytes), hashAlgorithm);
|
||||||
require(!evaluatedCFrags[evaluationHash]);
|
require(!evaluatedCFrags[evaluationHash], "This CFrag has already been evaluated.");
|
||||||
|
|
||||||
// Verify requester's signature of Capsule
|
// Verify requester's signature of Capsule
|
||||||
bytes memory preparedPublicKey = new bytes(64);
|
bytes memory preparedPublicKey = new bytes(64);
|
||||||
|
|
|
@ -40,8 +40,9 @@ def token(testerchain):
|
||||||
def escrow_contract(testerchain, token, request):
|
def escrow_contract(testerchain, token, request):
|
||||||
def make_escrow(max_allowed_locked_tokens):
|
def make_escrow(max_allowed_locked_tokens):
|
||||||
# Creator deploys the escrow
|
# Creator deploys the escrow
|
||||||
|
_mining_coefficient = 2 * 10 ** 7
|
||||||
contract, _ = testerchain.interface.deploy_contract(
|
contract, _ = testerchain.interface.deploy_contract(
|
||||||
'MinersEscrow', token.address, 1, 4 * 2 * 10 ** 7, 4, 4, 2, 100, max_allowed_locked_tokens)
|
'MinersEscrow', token.address, 1, 4 * _mining_coefficient, 4, 4, 2, 100, max_allowed_locked_tokens)
|
||||||
|
|
||||||
if request.param:
|
if request.param:
|
||||||
secret_hash = testerchain.interface.w3.keccak(secret)
|
secret_hash = testerchain.interface.w3.keccak(secret)
|
||||||
|
|
Loading…
Reference in New Issue