From c9f2e67594b7e92dd6e3df606e7c6a4aa785ad02 Mon Sep 17 00:00:00 2001 From: bumi Date: Sun, 8 Apr 2018 14:56:32 +0200 Subject: [PATCH] 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. --- contracts/Operator.sol | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contracts/Operator.sol b/contracts/Operator.sol index f7a51e6..1996439 100644 --- a/contracts/Operator.sol +++ b/contracts/Operator.sol @@ -95,6 +95,12 @@ contract Operator is Upgradeable { 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) { var p = proposals[_proposalId]; require(!p.executed); -- 2.25.1