-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprivate_ledger.sol
49 lines (38 loc) · 981 Bytes
/
private_ledger.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
39
40
41
42
43
44
45
46
47
48
49
contract PrivateLedger {
address public owner;
address[] members;
bytes[] public transactions;
modifier isOwner {
if (msg.sender == owner) _
}
modifier isMember {
for (uint i = 0; i < members.length; i++) {
if (msg.sender == members[i]) _
}
}
event NewTransaction(uint id);
function PrivateLedger() {
owner = msg.sender;
}
function addMember(address member) isOwner {
members[members.length++] = member;
}
function removeMember(address member) isOwner {
for (uint i = 0; i < members.length; i++) {
if (member == members[i]) {
delete members[i];
}
}
}
function getMembers() isOwner constant returns (address[]) {
return members;
}
function addTransaction(bytes transaction) isMember {
uint id = transactions.length++;
transactions[id] = transaction;
NewTransaction(id);
}
function numTransactions() constant returns (uint) {
return transactions.length;
}
}