[Storage] Move missingProofs() to Proofs

This commit is contained in:
Mark Spanbroek 2023-01-09 14:41:28 +01:00 committed by markspanbroek
parent 154cc00277
commit c9cf47f327
4 changed files with 5 additions and 13 deletions

View File

@ -53,8 +53,8 @@ contract Proofs {
return _end(_requestId(id));
}
function _missed(SlotId id) internal view returns (uint256) {
return missed[id];
function missingProofs(SlotId slotId) public view returns (uint256) {
return missed[slotId];
}
function periodOf(uint256 timestamp) private view returns (uint256) {

View File

@ -35,10 +35,6 @@ contract Storage is Marketplace {
minCollateralThreshold = _minCollateralThreshold;
}
function missingProofs(SlotId slotId) public view returns (uint256) {
return _missed(slotId);
}
function isProofRequired(SlotId slotId) public view returns (bool) {
if (!_slotAcceptsProofs(slotId)) {
return false;
@ -74,7 +70,7 @@ contract Storage is Marketplace {
{
_markProofAsMissing(slotId, period);
address host = _host(slotId);
if (_missed(slotId) % slashMisses == 0) {
if (missingProofs(slotId) % slashMisses == 0) {
_slash(host, slashPercentage);
if (balanceOf(host) < minCollateralThreshold) {

View File

@ -28,10 +28,6 @@ contract TestProofs is Proofs {
return _end(id);
}
function missed(SlotId id) public view returns (uint256) {
return _missed(id);
}
function expectProofs(
SlotId slot,
RequestId request,

View File

@ -211,12 +211,12 @@ describe("Proofs", function () {
})
it("marks a proof as missing", async function () {
expect(await proofs.missed(slotId)).to.equal(0)
expect(await proofs.missingProofs(slotId)).to.equal(0)
await waitUntilProofIsRequired(slotId)
let missedPeriod = periodOf(await currentTime())
await advanceTimeTo(periodEnd(missedPeriod))
await proofs.markProofAsMissing(slotId, missedPeriod)
expect(await proofs.missed(slotId)).to.equal(1)
expect(await proofs.missingProofs(slotId)).to.equal(1)
})
it("does not mark a proof as missing before period end", async function () {