mirror of
https://github.com/codex-storage/codex-contracts-eth.git
synced 2025-01-10 03:45:41 +00:00
add back proof end mappings
This commit is contained in:
parent
cfb70897f8
commit
2478e36aba
@ -75,7 +75,7 @@ contract Marketplace is Collateral, Proofs {
|
||||
ProofId proofId = _toProofId(slotId);
|
||||
_expectProofs(
|
||||
proofId,
|
||||
requestId,
|
||||
_toEndId(requestId),
|
||||
request.ask.proofProbability);
|
||||
_submitProof(proofId, proof);
|
||||
|
||||
@ -117,7 +117,7 @@ contract Marketplace is Collateral, Proofs {
|
||||
context.state == RequestState.Started) {
|
||||
|
||||
context.state = RequestState.Failed;
|
||||
_setProofEnd(requestId, block.timestamp - 1);
|
||||
_setProofEnd(_toEndId(requestId), block.timestamp - 1);
|
||||
context.endsAt = block.timestamp - 1;
|
||||
emit RequestFailed(requestId);
|
||||
|
||||
@ -254,7 +254,7 @@ contract Marketplace is Collateral, Proofs {
|
||||
return _timeout();
|
||||
}
|
||||
|
||||
function proofEnd(bytes32 slotId) public view returns (uint256) {
|
||||
function proofEnd(SlotId slotId) public view returns (uint256) {
|
||||
Slot memory slot = _slot(slotId);
|
||||
uint256 end = _end(_toEndId(slot.requestId));
|
||||
if (_slotAcceptsProofs(slotId)) {
|
||||
@ -337,12 +337,14 @@ contract Marketplace is Collateral, Proofs {
|
||||
return ProofId.wrap(SlotId.unwrap(slotId));
|
||||
}
|
||||
|
||||
function _toEndId(RequestId requestId) internal pure returns (EndId) {
|
||||
return EndId.wrap(RequestId.unwrap(requestId));
|
||||
}
|
||||
|
||||
function _notEqual(RequestId a, uint256 b) internal pure returns (bool) {
|
||||
return RequestId.unwrap(a) != bytes32(b);
|
||||
}
|
||||
|
||||
|
||||
struct Request {
|
||||
address client;
|
||||
Ask ask;
|
||||
|
@ -3,6 +3,7 @@ pragma solidity ^0.8.8;
|
||||
|
||||
contract Proofs {
|
||||
type ProofId is bytes32;
|
||||
type EndId is bytes32;
|
||||
|
||||
uint256 private immutable period;
|
||||
uint256 private immutable timeout;
|
||||
@ -37,7 +38,7 @@ contract Proofs {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
function _end(ProofId id) internal view returns (uint256) {
|
||||
function _end(EndId endId) internal view returns (uint256) {
|
||||
uint256 end = ends[endId];
|
||||
require(end > 0, "Proof ending doesn't exist");
|
||||
return ends[endId];
|
||||
@ -45,7 +46,7 @@ contract Proofs {
|
||||
|
||||
function _endId(ProofId id) internal view returns (EndId) {
|
||||
EndId endId = idEnds[id];
|
||||
require(endId > 0, "endId for given id doesn't exist");
|
||||
require(EndId.unwrap(endId) > 0, "endId for given id doesn't exist");
|
||||
return endId;
|
||||
}
|
||||
|
||||
@ -187,7 +188,7 @@ contract Proofs {
|
||||
/// @dev Can only be set once
|
||||
/// @param endId the endId of the proofs to extend (typically a request id).
|
||||
/// @param ending the new end time (in seconds)
|
||||
function _setProofEnd(bytes32 endId, uint256 ending) internal {
|
||||
function _setProofEnd(EndId endId, uint256 ending) internal {
|
||||
// TODO: create type aliases for id and endId so that _end() can return
|
||||
// EndId storage and we don't need to replicate the below require here
|
||||
require (ends[endId] == 0 || ending < block.timestamp, "End exists or must be past");
|
||||
|
@ -24,7 +24,7 @@ contract TestProofs is Proofs {
|
||||
return _timeout();
|
||||
}
|
||||
|
||||
function end(ProofId id) public view returns (uint256) {
|
||||
function end(EndId id) public view returns (uint256) {
|
||||
return _end(id);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ contract TestProofs is Proofs {
|
||||
_markProofAsMissing(id, _period);
|
||||
}
|
||||
|
||||
function setProofEnd(bytes32 id, uint256 ending) public {
|
||||
function setProofEnd(EndId id, uint256 ending) public {
|
||||
_setProofEnd(id, ending);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user