mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-02-26 21:30:35 +00:00
[Markeplace] Linting
This commit is contained in:
parent
afb89c9233
commit
afad73d588
@ -59,10 +59,9 @@ contract Marketplace is Collateral, Proofs {
|
||||
return RequestId.unwrap(a) == RequestId.unwrap(b);
|
||||
}
|
||||
|
||||
function requestStorage(Request calldata request)
|
||||
public
|
||||
marketplaceInvariant
|
||||
{
|
||||
function requestStorage(
|
||||
Request calldata request
|
||||
) public marketplaceInvariant {
|
||||
require(request.client == msg.sender, "Invalid client address");
|
||||
|
||||
RequestId id = _toRequestId(request);
|
||||
@ -129,10 +128,10 @@ contract Marketplace is Collateral, Proofs {
|
||||
}
|
||||
}
|
||||
|
||||
function markProofAsMissing(SlotId slotId, uint256 period)
|
||||
public
|
||||
slotMustAcceptProofs(slotId)
|
||||
{
|
||||
function markProofAsMissing(
|
||||
SlotId slotId,
|
||||
uint256 period
|
||||
) public slotMustAcceptProofs(slotId) {
|
||||
_markProofAsMissing(slotId, period);
|
||||
address host = _host(slotId);
|
||||
if (missingProofs(slotId) % slashMisses == 0) {
|
||||
@ -147,7 +146,9 @@ contract Marketplace is Collateral, Proofs {
|
||||
}
|
||||
}
|
||||
|
||||
function _forciblyFreeSlot(SlotId slotId)
|
||||
function _forciblyFreeSlot(
|
||||
SlotId slotId
|
||||
)
|
||||
internal
|
||||
slotMustAcceptProofs(slotId)
|
||||
marketplaceInvariant
|
||||
@ -188,10 +189,10 @@ contract Marketplace is Collateral, Proofs {
|
||||
}
|
||||
}
|
||||
|
||||
function payoutSlot(RequestId requestId, SlotId slotId)
|
||||
private
|
||||
marketplaceInvariant
|
||||
{
|
||||
function payoutSlot(
|
||||
RequestId requestId,
|
||||
SlotId slotId
|
||||
) private marketplaceInvariant {
|
||||
require(
|
||||
_isFinished(requestId) || _isCancelled(requestId),
|
||||
"Contract not ended"
|
||||
@ -266,11 +267,9 @@ contract Marketplace is Collateral, Proofs {
|
||||
/// @dev Returns requestId that is mapped to the slotId
|
||||
/// @param slotId id of the slot
|
||||
/// @return if of the request the slot belongs to
|
||||
function _getRequestIdForSlot(SlotId slotId)
|
||||
internal
|
||||
view
|
||||
returns (RequestId)
|
||||
{
|
||||
function _getRequestIdForSlot(
|
||||
SlotId slotId
|
||||
) internal view returns (RequestId) {
|
||||
Slot memory slot = _slot(slotId);
|
||||
require(_notEqual(slot.requestId, 0), "Missing request id");
|
||||
return slot.requestId;
|
||||
@ -293,21 +292,17 @@ contract Marketplace is Collateral, Proofs {
|
||||
return _host(slotId);
|
||||
}
|
||||
|
||||
function _request(RequestId requestId)
|
||||
internal
|
||||
view
|
||||
returns (Request storage)
|
||||
{
|
||||
function _request(
|
||||
RequestId requestId
|
||||
) internal view returns (Request storage) {
|
||||
Request storage request = requests[requestId];
|
||||
require(request.client != address(0), "Unknown request");
|
||||
return request;
|
||||
}
|
||||
|
||||
function getRequest(RequestId requestId)
|
||||
public
|
||||
view
|
||||
returns (Request memory)
|
||||
{
|
||||
function getRequest(
|
||||
RequestId requestId
|
||||
) public view returns (Request memory) {
|
||||
return _request(requestId);
|
||||
}
|
||||
|
||||
@ -317,11 +312,9 @@ contract Marketplace is Collateral, Proofs {
|
||||
return slot;
|
||||
}
|
||||
|
||||
function _context(RequestId requestId)
|
||||
internal
|
||||
view
|
||||
returns (RequestContext storage)
|
||||
{
|
||||
function _context(
|
||||
RequestId requestId
|
||||
) internal view returns (RequestContext storage) {
|
||||
return requestContexts[requestId];
|
||||
}
|
||||
|
||||
@ -413,61 +406,50 @@ contract Marketplace is Collateral, Proofs {
|
||||
/// @notice returns true when the request is accepting proof submissions from hosts occupying slots.
|
||||
/// @dev Request state must be new or started, and must not be cancelled, finished, or failed.
|
||||
/// @param requestId id of the request for which to obtain state info
|
||||
function _requestAcceptsProofs(RequestId requestId)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
function _requestAcceptsProofs(
|
||||
RequestId requestId
|
||||
) internal view returns (bool) {
|
||||
RequestState s = state(requestId);
|
||||
return s == RequestState.New || s == RequestState.Started;
|
||||
}
|
||||
|
||||
function _toRequestId(Request memory request)
|
||||
internal
|
||||
pure
|
||||
returns (RequestId)
|
||||
{
|
||||
function _toRequestId(
|
||||
Request memory request
|
||||
) internal pure returns (RequestId) {
|
||||
return RequestId.wrap(keccak256(abi.encode(request)));
|
||||
}
|
||||
|
||||
function _toRequestIds(bytes32[] memory array)
|
||||
private
|
||||
pure
|
||||
returns (RequestId[] memory result)
|
||||
{
|
||||
function _toRequestIds(
|
||||
bytes32[] memory array
|
||||
) private pure returns (RequestId[] memory result) {
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly {
|
||||
result := array
|
||||
}
|
||||
}
|
||||
|
||||
function _toSlotIds(bytes32[] memory array)
|
||||
private
|
||||
pure
|
||||
returns (SlotId[] memory result)
|
||||
{
|
||||
function _toSlotIds(
|
||||
bytes32[] memory array
|
||||
) private pure returns (SlotId[] memory result) {
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly {
|
||||
result := array
|
||||
}
|
||||
}
|
||||
|
||||
function _toBytes32s(RequestId[] memory array)
|
||||
private
|
||||
pure
|
||||
returns (bytes32[] memory result)
|
||||
{
|
||||
function _toBytes32s(
|
||||
RequestId[] memory array
|
||||
) private pure returns (bytes32[] memory result) {
|
||||
// solhint-disable-next-line no-inline-assembly
|
||||
assembly {
|
||||
result := array
|
||||
}
|
||||
}
|
||||
|
||||
function _toSlotId(RequestId requestId, uint256 slotIndex)
|
||||
internal
|
||||
pure
|
||||
returns (SlotId)
|
||||
{
|
||||
function _toSlotId(
|
||||
RequestId requestId,
|
||||
uint256 slotIndex
|
||||
) internal pure returns (SlotId) {
|
||||
return SlotId.wrap(keccak256(abi.encode(requestId, slotIndex)));
|
||||
}
|
||||
|
||||
|
@ -8,11 +8,7 @@ contract Proofs {
|
||||
uint256 private immutable timeout;
|
||||
uint8 private immutable downtime;
|
||||
|
||||
constructor(
|
||||
uint256 __period,
|
||||
uint256 __timeout,
|
||||
uint8 __downtime
|
||||
) {
|
||||
constructor(uint256 __period, uint256 __timeout, uint8 __downtime) {
|
||||
require(block.number > 256, "Insufficient block height");
|
||||
period = __period;
|
||||
timeout = __timeout;
|
||||
@ -87,11 +83,10 @@ contract Proofs {
|
||||
ids[id] = false;
|
||||
}
|
||||
|
||||
function _getPointer(SlotId id, uint256 proofPeriod)
|
||||
internal
|
||||
view
|
||||
returns (uint8)
|
||||
{
|
||||
function _getPointer(
|
||||
SlotId id,
|
||||
uint256 proofPeriod
|
||||
) internal view returns (uint8) {
|
||||
uint256 blockNumber = block.number % 256;
|
||||
uint256 periodNumber = proofPeriod % 256;
|
||||
uint256 idOffset = uint256(SlotId.unwrap(id)) % 256;
|
||||
@ -109,11 +104,10 @@ contract Proofs {
|
||||
return keccak256(abi.encode(hash));
|
||||
}
|
||||
|
||||
function _getChallenge(SlotId id, uint256 proofPeriod)
|
||||
internal
|
||||
view
|
||||
returns (bytes32)
|
||||
{
|
||||
function _getChallenge(
|
||||
SlotId id,
|
||||
uint256 proofPeriod
|
||||
) internal view returns (bytes32) {
|
||||
return _getChallenge(_getPointer(id, proofPeriod));
|
||||
}
|
||||
|
||||
@ -121,11 +115,10 @@ contract Proofs {
|
||||
return _getChallenge(id, currentPeriod());
|
||||
}
|
||||
|
||||
function _getProofRequirement(SlotId id, uint256 proofPeriod)
|
||||
internal
|
||||
view
|
||||
returns (bool isRequired, uint8 pointer)
|
||||
{
|
||||
function _getProofRequirement(
|
||||
SlotId id,
|
||||
uint256 proofPeriod
|
||||
) internal view returns (bool isRequired, uint8 pointer) {
|
||||
if (proofPeriod <= periodOf(starts[id])) {
|
||||
return (false, 0);
|
||||
}
|
||||
@ -139,11 +132,10 @@ contract Proofs {
|
||||
isRequired = ids[id] && uint256(challenge) % probability == 0;
|
||||
}
|
||||
|
||||
function _isProofRequired(SlotId id, uint256 proofPeriod)
|
||||
internal
|
||||
view
|
||||
returns (bool)
|
||||
{
|
||||
function _isProofRequired(
|
||||
SlotId id,
|
||||
uint256 proofPeriod
|
||||
) internal view returns (bool) {
|
||||
bool isRequired;
|
||||
uint8 pointer;
|
||||
(isRequired, pointer) = _getProofRequirement(id, proofPeriod);
|
||||
|
Loading…
x
Reference in New Issue
Block a user