Merge pull request #134 from thanhson1085/master

remove nodeId in smart contract
This commit is contained in:
Tuna 2018-08-14 16:58:39 +07:00 committed by GitHub
commit 4d1aa5ea51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 206 deletions

View file

@ -9,12 +9,10 @@ contract TomoValidator {
event Unvote(address _voter, address _candidate, uint256 _cap);
event Propose(address _owner, address _candidate, uint256 _cap);
event Resign(address _owner, address _candidate);
event SetNodeId(address _owner, address _candidate, string _nodeId);
event Withdraw(address _owner, uint256 _blockNumber, uint256 _cap);
struct ValidatorState {
address owner;
string nodeId;
bool isCandidate;
uint256 cap;
mapping(address => uint256) voters;
@ -97,7 +95,6 @@ contract TomoValidator {
candidates.push(_candidates[i]);
validatorsState[_candidates[i]] = ValidatorState({
owner: _firstOwner,
nodeId: '',
isCandidate: true,
cap: _caps[i]
});
@ -106,11 +103,10 @@ contract TomoValidator {
}
}
function propose(address _candidate, string _nodeId) external payable onlyValidCandidateCap onlyNotCandidate(_candidate) {
function propose(address _candidate) external payable onlyValidCandidateCap onlyNotCandidate(_candidate) {
candidates.push(_candidate);
validatorsState[_candidate] = ValidatorState({
owner: msg.sender,
nodeId: _nodeId,
isCandidate: true,
cap: msg.value
});
@ -137,10 +133,6 @@ contract TomoValidator {
return validatorsState[_candidate].cap;
}
function getCandidateNodeId(address _candidate) public view returns(string) {
return validatorsState[_candidate].nodeId;
}
function getCandidateOwner(address _candidate) public view returns(address) {
return validatorsState[_candidate].owner;
}
@ -177,11 +169,6 @@ contract TomoValidator {
emit Unvote(msg.sender, _candidate, _cap);
}
function setNodeId(address _candidate, string _nodeId) public onlyOwner(_candidate) {
validatorsState[_candidate].nodeId = _nodeId;
emit SetNodeId(msg.sender, _candidate, _nodeId);
}
function resign(address _candidate) public onlyOwner(_candidate) onlyCandidate(_candidate) {
validatorsState[_candidate].isCandidate = false;
candidateCount = candidateCount - 1;

View file

@ -1,6 +0,0 @@
pragma solidity ^0.4.21;
interface IValidator {
function propose(address, string) external payable;
function vote(address) external payable;
}

File diff suppressed because one or more lines are too long

View file

@ -114,7 +114,7 @@ func TestRewardBalance(t *testing.T) {
opts := bind.NewKeyedTransactor(acc4Key)
opts.Value = new(big.Int).SetUint64(50000)
acc4Validator, _ := NewValidator(opts, validatorAddr, contractBackend)
acc4Validator.Propose(acc3Addr, "http://")
acc4Validator.Propose(acc3Addr)
contractBackend.Commit()
totalVote := 0