-
Notifications
You must be signed in to change notification settings - Fork 15
/
Stake.sol
38 lines (30 loc) · 998 Bytes
/
Stake.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
contract Stake {
mapping (address => uint) stake; // percentages by address (basically)
address[] stakeHolders; // to iterate over
address holdingTheBag; // last arrival to the party
uint numStakeHolders;
uint currentStake;
uint sumStake;
function Stake() {
currentStake = 100; /* the number doesn't really matter, payout computed by ratio anyway */
sumStake = 0;
numStakeHolders = 0;
}
function addStakeHolder(address stakeholder) {
stake[stakeholder] = currentStake;
stakeHolders.length = numStakeHolders+1;
stakeHolders[numStakeHolders] = stakeholder;
numStakeHolders++;
holdingTheBag = stakeholder;
sumStake += currentStake;
currentStake = currentStake / 2; // note that this is not a get what you put in sort of scheme
}
function payout() {
uint bal = this.balance;
uint j;
for (j = 0; j < stakeHolders.length; j++)
{
stakeHolders[j].send(bal * stake[stakeHolders[j]] / sumStake);
}
}
}