Fix: access the pubkey array length once

This commit is contained in:
Richard Ramos 2022-08-09 14:00:08 -04:00
parent 2abc054713
commit dc2a1393ef
1 changed files with 4 additions and 3 deletions

View File

@ -33,9 +33,10 @@ contract RLN {
}
function registerBatch(uint256[] calldata pubkeys) external payable {
require(pubkeyIndex + pubkeys.length <= SET_SIZE, "RLN, registerBatch: set is full");
require(msg.value == MEMBERSHIP_DEPOSIT * pubkeys.length, "RLN, registerBatch: membership deposit is not satisfied");
for (uint256 i = 0; i < pubkeys.length; i++) {
uint256 pubkeylen = pubkeys.length;
require(pubkeyIndex + pubkeylen <= SET_SIZE, "RLN, registerBatch: set is full");
require(msg.value == MEMBERSHIP_DEPOSIT * pubkeylen, "RLN, registerBatch: membership deposit is not satisfied");
for (uint256 i = 0; i < pubkeylen; i++) {
_register(pubkeys[i]);
}
}