mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-11 01:33:08 +00:00
Not needed, as a slot that cannot be added due to already being included would revert anyway.
28 lines
828 B
Solidity
28 lines
828 B
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity 0.8.23;
|
|
|
|
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
|
|
import "./Requests.sol";
|
|
|
|
contract SlotReservations {
|
|
using EnumerableSet for EnumerableSet.AddressSet;
|
|
|
|
mapping(SlotId => EnumerableSet.AddressSet) internal _reservations;
|
|
|
|
uint8 private constant _MAX_RESERVATIONS = 3;
|
|
|
|
function reserveSlot(SlotId slotId) public {
|
|
address host = msg.sender;
|
|
require(canReserveSlot(slotId), "Reservation not allowed");
|
|
_reservations[slotId].add(host);
|
|
}
|
|
|
|
function canReserveSlot(SlotId slotId) public view returns (bool) {
|
|
address host = msg.sender;
|
|
return
|
|
// TODO: add in check for address inside of expanding window
|
|
(_reservations[slotId].length() < _MAX_RESERVATIONS) &&
|
|
(!_reservations[slotId].contains(host));
|
|
}
|
|
}
|