-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(poll): add message batch submission
Allow to submit a message batch with n numbers of messages and encPubKeys
- Loading branch information
Showing
2 changed files
with
71 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,7 @@ contract Poll is Params, Utilities, SnarkCommon, Ownable, EmptyBallotRoots, IPol | |
error MaciPubKeyLargerThanSnarkFieldSize(); | ||
error StateAqAlreadyMerged(); | ||
error StateAqSubtreesNeedMerge(); | ||
error InvalidBatchLength(); | ||
|
||
event PublishMessage(Message _message, PubKey _encPubKey); | ||
event TopupMessage(Message _message); | ||
|
@@ -197,6 +198,26 @@ contract Poll is Params, Utilities, SnarkCommon, Ownable, EmptyBallotRoots, IPol | |
emit PublishMessage(_message, _encPubKey); | ||
} | ||
|
||
/// @notice submit a message batch | ||
/// @dev Can only be submitted before the voting deadline | ||
/// @param _messages the messages | ||
/// @param _encPubKeys the encrypted public keys | ||
function publishMessageBatch(Message[] calldata _messages, PubKey[] calldata _encPubKeys) external { | ||
Check warning Code scanning / Slither Conformance to Solidity naming conventions Warning
Parameter Poll.publishMessageBatch(DomainObjs.Message[],DomainObjs.PubKey[])._encPubKeys is not in mixedCase
Check warning Code scanning / Slither Conformance to Solidity naming conventions Warning
Parameter Poll.publishMessageBatch(DomainObjs.Message[],DomainObjs.PubKey[])._messages is not in mixedCase
|
||
if (_messages.length != _encPubKeys.length) { | ||
revert InvalidBatchLength(); | ||
} | ||
|
||
uint256 len = _messages.length; | ||
for (uint256 i = 0; i < len; ) { | ||
// an event will be published by this function already | ||
publishMessage(_messages[i], _encPubKeys[i]); | ||
|
||
unchecked { | ||
i++; | ||
} | ||
} | ||
} | ||
|
||
/// @inheritdoc IPoll | ||
function mergeMaciStateAqSubRoots(uint256 _numSrQueueOps, uint256 _pollId) public onlyOwner isAfterVotingDeadline { | ||
// This function cannot be called after the stateAq was merged | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters