Skip to content
Permalink
Browse files

Implemented validator set, fix #54

  • Loading branch information...
akru committed Jan 15, 2019
1 parent b713110 commit 6b50af5a159c2cf23d607b59de6441741b4e7632
Showing with 13 additions and 23 deletions.
  1. +10 −10 contracts/robonomics/Liability.sol
  2. +3 −13 contracts/robonomics/interface/IValidator.sol
@@ -131,22 +131,22 @@ contract Liability is ILiability {
require(msg.sender == lighthouse);
require(!isFinalized);

isFinalized = true;
result = _result;
isSuccess = _success;

address resultSender = keccak256(abi.encodePacked(this, _result, _success))
.toEthSignedMessageHash()
.recover(_signature);
require(resultSender == promisor);

isFinalized = true;
result = _result;

if (validator == address(0)) {
// Set state of liability according promisor report only
isSuccess = _success;
require(resultSender == promisor);
} else {
// Validator can take a fee for decision
xrt.safeApprove(validator, validatorFee);
// Set state of liability considering validator decision
isSuccess = _success && IValidator(validator).decision();
require(IValidator(validator).isValidator(resultSender));
// Transfer validator fee when is set
if (validatorFee > 0)
xrt.safeTransfer(validator, validatorFee);

}

if (cost > 0)
@@ -5,18 +5,8 @@ pragma solidity ^0.5.0;
*/
contract IValidator {
/**
* @dev Final liability decision
* @dev Be sure than address is really validator
* @return true when validator address in argument
*/
event Decision(address indexed liability, bool indexed success);

/**
* @dev Decision availability marker
*/
mapping(address => bool) public hasDecision;

/**
* @dev Get decision of liability, is used by liability contract only
* @notice Transaction will fail when have no decision
*/
function decision() external returns (bool);
function isValidator(address _validator) external returns (bool);
}

0 comments on commit 6b50af5

Please sign in to comment.
You can’t perform that action at this time.