diff --git a/contracts/Conference.sol b/contracts/Conference.sol index 3e6fbee..cc9af61 100644 --- a/contracts/Conference.sol +++ b/contracts/Conference.sol @@ -8,7 +8,6 @@ contract Conference is Destructible { string public name; uint256 public deposit; uint public limitOfParticipants; - uint public registered; uint public attended; bool public ended; bool public cancelled; @@ -19,7 +18,7 @@ contract Conference is Destructible { string public encryption; mapping (address => Participant) public participants; - mapping (uint => address) public participantsIndex; + address[] public participantsIndex; bool paid; struct Participant { @@ -102,11 +101,10 @@ contract Conference is Destructible { function registerInternal(string _participant) internal { require(msg.value == deposit); - require(registered < limitOfParticipants); + require(registered() < limitOfParticipants); require(!isRegistered(msg.sender)); - registered++; - participantsIndex[registered] = msg.sender; + participantsIndex.push(msg.sender); participants[msg.sender] = Participant(_participant, msg.sender, false, false); } @@ -133,6 +131,14 @@ contract Conference is Destructible { } /* Constants */ + function registered() constant returns(uint){ + return participantsIndex.length; + } + + function getParticipants() constant returns (address[]){ + return participantsIndex; + } + function totalBalance() constant returns (uint256){ return this.balance; } diff --git a/log/stress_0002.log b/log/stress_0002.log index eb8f588..f579628 100644 --- a/log/stress_0002.log +++ b/log/stress_0002.log @@ -1,7 +1,7 @@ type gasUsed gasPrice 1ETH*USD gasUsed*gasPrice(Ether) gasUsed*gasPrice(USD) -create 1686592 2 303 0.003373184 1.022074752 -addConfirmation 89601 2 303 0.000179202 0.054298206 -register 119996 2 303 0.000239992 0.07271757599999999 -batchAttend 67248 2 303 0.000134496 0.040752288000000005 -payback 84552 2 303 0.000169104 0.051238512 +create 1764065 2 303 0.00352813 1.06902339 +addConfirmation 89537 2 303 0.000179074 0.054259421999999995 +register 120265 2 303 0.00024053 0.07288059 +batchAttend 67270 2 303 0.00013454 0.040765619999999995 +payback 84574 2 303 0.000169148 0.051251844 withdraw 37890 2 303 0.00007578 0.02296134 diff --git a/log/stress_0020.log b/log/stress_0020.log index a71f785..421bf93 100644 --- a/log/stress_0020.log +++ b/log/stress_0020.log @@ -1,7 +1,7 @@ type gasUsed gasPrice 1ETH*USD gasUsed*gasPrice(Ether) gasUsed*gasPrice(USD) -create 1686592 2 303 0.003373184 1.022074752 -addConfirmation 694042 2 303 0.001388084 0.420589452 -register 119996 2 303 0.000239992 0.07271757599999999 -batchAttend 331147 2 303 0.000662294 0.200675082 -payback 84552 2 303 0.000169104 0.051238512 +create 1764065 2 303 0.00352813 1.06902339 +addConfirmation 693978 2 303 0.001387956 0.420550668 +register 120265 2 303 0.00024053 0.07288059 +batchAttend 331105 2 303 0.00066221 0.20064963 +payback 84574 2 303 0.000169148 0.051251844 withdraw 37890 2 303 0.00007578 0.02296134 diff --git a/log/stress_0100.log b/log/stress_0100.log index afa8b56..7fa9404 100644 --- a/log/stress_0100.log +++ b/log/stress_0100.log @@ -1,7 +1,7 @@ type gasUsed gasPrice 1ETH*USD gasUsed*gasPrice(Ether) gasUsed*gasPrice(USD) -create 1686592 2 303 0.003373184 1.022074752 -addConfirmation 3381099 2 303 0.006762198 2.048945994 -register 119996 2 303 0.000239992 0.07271757599999999 -batchAttend 1503663 2 303 0.003007326 0.911219778 -payback 84552 2 303 0.000169104 0.051238512 +create 1764065 2 303 0.00352813 1.06902339 +addConfirmation 3381035 2 303 0.00676207 2.04890721 +register 120265 2 303 0.00024053 0.07288059 +batchAttend 1503749 2 303 0.003007498 0.911271894 +payback 84574 2 303 0.000169148 0.051251844 withdraw 37890 2 303 0.00007578 0.02296134 diff --git a/log/stress_0200.log b/log/stress_0200.log index 41ccad9..0b93708 100644 --- a/log/stress_0200.log +++ b/log/stress_0200.log @@ -1,6 +1,6 @@ type gasUsed gasPrice 1ETH*USD gasUsed*gasPrice(Ether) gasUsed*gasPrice(USD) -create 1692580 2 303 0.00338516 1.02570348 -register 119815 2 303 0.00023963 0.07260789000000001 -batchAttend 2969251 2 303 0.005938502 1.799366106 -payback 84325 2 303 0.00016865 0.05110095 -withdraw 37660 2 303 0.00007532 0.022821960000000002 +create 1764065 2 303 0.00352813 1.06902339 +register 120265 2 303 0.00024053 0.07288059 +batchAttend 2969398 2 303 0.005938796 1.7994551879999998 +payback 84574 2 303 0.000169148 0.051251844 +withdraw 37890 2 303 0.00007578 0.02296134 diff --git a/log/stress_0300.log b/log/stress_0300.log index b10a7d7..bf32394 100644 --- a/log/stress_0300.log +++ b/log/stress_0300.log @@ -1,6 +1,6 @@ type gasUsed gasPrice 1ETH*USD gasUsed*gasPrice(Ether) gasUsed*gasPrice(USD) -create 1692644 2 303 0.003385288 1.025742264 -register 119815 2 303 0.00023963 0.07260789000000001 -batchAttend 4434618 2 303 0.008869236 2.687378508 -payback 84325 2 303 0.00016865 0.05110095 -withdraw 37660 2 303 0.00007532 0.022821960000000002 +create 1764129 2 303 0.003528258 1.069062174 +register 120265 2 303 0.00024053 0.07288059 +batchAttend 4435021 2 303 0.008870042 2.687622726 +payback 84574 2 303 0.000169148 0.051251844 +withdraw 37890 2 303 0.00007578 0.02296134 diff --git a/test/conference.js b/test/conference.js index ccb31aa..0c12cb6 100644 --- a/test/conference.js +++ b/test/conference.js @@ -78,6 +78,10 @@ contract('Conference', function(accounts) { assert.equal((await conference.registered.call()).toNumber(), 1); }) + it('getParticipants returns list of addresses', async function(){ + assert.equal((await conference.getParticipants.call())[0], owner); + }) + it('increases totalBalance', async function(){ assert.equal((await conference.totalBalance.call()) - beforeContractBalance , deposit); })