From c9cf47f3271c1acca826cbc1ea0f63218005d143 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Mon, 9 Jan 2023 14:41:28 +0100 Subject: [PATCH] [Storage] Move missingProofs() to Proofs --- contracts/Proofs.sol | 4 ++-- contracts/Storage.sol | 6 +----- contracts/TestProofs.sol | 4 ---- test/Proofs.test.js | 4 ++-- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/contracts/Proofs.sol b/contracts/Proofs.sol index 2b7539f..f8a5eac 100644 --- a/contracts/Proofs.sol +++ b/contracts/Proofs.sol @@ -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) { diff --git a/contracts/Storage.sol b/contracts/Storage.sol index 36795a6..5e6aa40 100644 --- a/contracts/Storage.sol +++ b/contracts/Storage.sol @@ -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) { diff --git a/contracts/TestProofs.sol b/contracts/TestProofs.sol index 2205737..3a9954d 100644 --- a/contracts/TestProofs.sol +++ b/contracts/TestProofs.sol @@ -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, diff --git a/test/Proofs.test.js b/test/Proofs.test.js index 7483ea0..d2df518 100644 --- a/test/Proofs.test.js +++ b/test/Proofs.test.js @@ -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 () {