Merge pull request #124 from thanhson1085/master

update Tomo Validator smart contract, add getWithdrawCap function
This commit is contained in:
Tuna 2018-08-10 14:43:19 +07:00 committed by GitHub
commit 7aae7f9cac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View file

@ -113,7 +113,7 @@ contract TomoValidator {
}); });
validatorsState[_candidate].voters[msg.sender] = msg.value; validatorsState[_candidate].voters[msg.sender] = msg.value;
candidateCount = candidateCount + 1; candidateCount = candidateCount + 1;
voters[_candidate].push(_candidate); voters[_candidate].push(msg.sender);
emit Propose(msg.sender, _candidate, msg.value); emit Propose(msg.sender, _candidate, msg.value);
} }
@ -158,6 +158,10 @@ contract TomoValidator {
return withdrawsState[msg.sender].blockNumbers; return withdrawsState[msg.sender].blockNumbers;
} }
function getWithdrawCap(uint256 _blockNumber) public view returns(uint256) {
return withdrawsState[msg.sender].caps[_blockNumber];
}
function unvote(address _candidate, uint256 _cap) public onlyValidVote(_candidate, _cap) { function unvote(address _candidate, uint256 _cap) public onlyValidVote(_candidate, _cap) {
validatorsState[_candidate].cap = validatorsState[_candidate].cap.sub(_cap); validatorsState[_candidate].cap = validatorsState[_candidate].cap.sub(_cap);
validatorsState[_candidate].voters[msg.sender] = validatorsState[_candidate].voters[msg.sender].sub(_cap); validatorsState[_candidate].voters[msg.sender] = validatorsState[_candidate].voters[msg.sender].sub(_cap);

File diff suppressed because one or more lines are too long