fix: use modifier for usable storage
This commit is contained in:
parent
ae01148ffc
commit
002c0f1213
|
@ -20,6 +20,11 @@ contract WakuRlnRegistry is Ownable {
|
||||||
|
|
||||||
event NewStorageContract(uint16 index, address storageAddress);
|
event NewStorageContract(uint16 index, address storageAddress);
|
||||||
|
|
||||||
|
modifier onlyUsableStorage() {
|
||||||
|
if (usingStorageIndex >= nextStorageIndex) revert NoStorageContractAvailable();
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(address _poseidonHasher) Ownable() {
|
constructor(address _poseidonHasher) Ownable() {
|
||||||
poseidonHasher = IPoseidonHasher(_poseidonHasher);
|
poseidonHasher = IPoseidonHasher(_poseidonHasher);
|
||||||
}
|
}
|
||||||
|
@ -43,9 +48,7 @@ contract WakuRlnRegistry is Ownable {
|
||||||
_insertIntoStorageMap(address(newStorageContract));
|
_insertIntoStorageMap(address(newStorageContract));
|
||||||
}
|
}
|
||||||
|
|
||||||
function register(uint256[] calldata commitments) external payable {
|
function register(uint256[] calldata commitments) external payable onlyUsableStorage {
|
||||||
if (usingStorageIndex >= nextStorageIndex) revert NoStorageContractAvailable();
|
|
||||||
|
|
||||||
// iteratively check if the storage contract is full, and increment the usingStorageIndex if it is
|
// iteratively check if the storage contract is full, and increment the usingStorageIndex if it is
|
||||||
while (true) {
|
while (true) {
|
||||||
try WakuRln(storages[usingStorageIndex]).register(commitments) {
|
try WakuRln(storages[usingStorageIndex]).register(commitments) {
|
||||||
|
@ -77,8 +80,7 @@ contract WakuRlnRegistry is Ownable {
|
||||||
WakuRln(storages[storageIndex]).register(commitments);
|
WakuRln(storages[storageIndex]).register(commitments);
|
||||||
}
|
}
|
||||||
|
|
||||||
function forceProgress() external onlyOwner {
|
function forceProgress() external onlyOwner onlyUsableStorage {
|
||||||
if (usingStorageIndex >= nextStorageIndex) revert NoStorageContractAvailable();
|
|
||||||
usingStorageIndex += 1;
|
usingStorageIndex += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,6 +148,12 @@ contract IPoseidonHasher poseidonHasher
|
||||||
event NewStorageContract(uint16 index, address storageAddress)
|
event NewStorageContract(uint16 index, address storageAddress)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### onlyUsableStorage
|
||||||
|
|
||||||
|
```solidity
|
||||||
|
modifier onlyUsableStorage()
|
||||||
|
```
|
||||||
|
|
||||||
### constructor
|
### constructor
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
|
|
Loading…
Reference in New Issue