Add function to batch votings

The batchVote function accepts an array of proposal ids and votes for
every one.
Normally arrays without fix length are problematic and gas usage can not be
estimated really well. So we need to see how that works or what other
pattern could be used.
This commit is contained in:
bumi 2018-04-08 14:56:32 +02:00
parent ef3b3dd6bb
commit c9f2e67594

View File

@ -95,6 +95,12 @@ contract Operator is Upgradeable {
ProposalCreated(proposalId, msg.sender, p.recipientId, p.amount); ProposalCreated(proposalId, msg.sender, p.recipientId, p.amount);
} }
function batchVote(uint256[] _proposalIds) public coreOnly {
for (uint256 i = 0; i < _proposalIds.length; i++) {
vote(_proposalIds[i]);
}
}
function vote(uint256 _proposalId) public coreOnly returns (uint _pId, bool _executed) { function vote(uint256 _proposalId) public coreOnly returns (uint _pId, bool _executed) {
var p = proposals[_proposalId]; var p = proposals[_proposalId];
require(!p.executed); require(!p.executed);