remove nodeId in smart contract

This commit is contained in:
Nguyen Sy Thanh Son 2018-08-14 04:17:27 +00:00
parent 3c1405fb14
commit 35013571d5
2 changed files with 15 additions and 199 deletions

View file

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

File diff suppressed because one or more lines are too long