Last active
November 3, 2018 18:33
-
-
Save atvanguard/05aaba1da62503a427021d40f35e62e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
contract LiquidDemocracy { | |
enum State {Invalid, Created, Voted, Delegated} | |
struct Proposal { | |
string description; | |
uint numVotes; | |
} | |
Proposal[] public proposals; | |
address[] validVoters; | |
struct Voter { | |
uint vote; // index of the proposal voted for in proposals[] | |
uint delegatedTo; // index of the fellow voter in validVoters[], the vote has been delegated to | |
uint index; // index of the this voter in validVoters[] | |
State state; | |
} | |
mapping(address => Voter) public voters; | |
function addVoter(address voter) public { | |
voters[voter] = Voter(0, 0, validVoters.length, State.Created); | |
validVoters.push(voter); | |
} | |
function newProposal(string description) public { | |
proposals.push(Proposal(description, 0)); | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment