mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-03 13:53:10 +00:00
marketplace: simplify requestEnd()
This commit is contained in:
parent
7a566182d5
commit
9603025202
@ -478,19 +478,10 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
|
||||
function requestEnd(RequestId requestId) public view returns (Timestamp) {
|
||||
RequestState state = requestState(requestId);
|
||||
if (
|
||||
state == RequestState.New ||
|
||||
state == RequestState.Started ||
|
||||
state == RequestState.Failed
|
||||
) {
|
||||
return _requestContexts[requestId].endsAt;
|
||||
}
|
||||
if (state == RequestState.Cancelled) {
|
||||
return _requestContexts[requestId].expiresAt;
|
||||
}
|
||||
Timestamp currentTime = Timestamps.currentTime();
|
||||
Timestamp end = _requestContexts[requestId].endsAt;
|
||||
return Timestamps.earliest(end, currentTime);
|
||||
return _requestContexts[requestId].endsAt;
|
||||
}
|
||||
|
||||
function requestExpiry(RequestId requestId) public view returns (Timestamp) {
|
||||
|
||||
@ -67,16 +67,4 @@ library Timestamps {
|
||||
) internal pure returns (Duration) {
|
||||
return Duration.wrap(Timestamp.unwrap(end) - Timestamp.unwrap(start));
|
||||
}
|
||||
|
||||
/// Returns the earliest of the two timestamps
|
||||
function earliest(
|
||||
Timestamp a,
|
||||
Timestamp b
|
||||
) internal pure returns (Timestamp) {
|
||||
if (a <= b) {
|
||||
return a;
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user