[marketplace] Rename Erasure.totalNodes -> Ask.slots
This commit is contained in:
parent
b3fededbad
commit
1d951ef8f8
|
@ -54,7 +54,7 @@ contract Marketplace is Collateral, Proofs {
|
|||
Request storage request = requests[requestId];
|
||||
require(request.client != address(0), "Unknown request");
|
||||
require(request.expiry > block.timestamp, "Request expired");
|
||||
require(slotIndex < request.content.erasure.totalNodes, "Invalid slot");
|
||||
require(slotIndex < request.ask.slots, "Invalid slot");
|
||||
|
||||
bytes32 slotId = keccak256(abi.encode(requestId, slotIndex));
|
||||
Slot storage slot = slots[slotId];
|
||||
|
@ -70,7 +70,7 @@ contract Marketplace is Collateral, Proofs {
|
|||
slot.host = msg.sender;
|
||||
state.slotsFilled += 1;
|
||||
emit SlotFilled(requestId, slotIndex, slotId);
|
||||
if (state.slotsFilled == request.content.erasure.totalNodes) {
|
||||
if (state.slotsFilled == request.ask.slots) {
|
||||
emit RequestFulfilled(requestId);
|
||||
}
|
||||
}
|
||||
|
@ -124,6 +124,7 @@ contract Marketplace is Collateral, Proofs {
|
|||
uint256 duration; // how long content should be stored (in seconds)
|
||||
uint256 proofProbability; // how often storage proofs are required
|
||||
uint256 reward; // reward that the client will pay (in number of tokens)
|
||||
uint64 slots; // the total number of hosts that store the data set
|
||||
}
|
||||
|
||||
struct Content {
|
||||
|
@ -134,7 +135,6 @@ contract Marketplace is Collateral, Proofs {
|
|||
|
||||
struct Erasure {
|
||||
uint64 totalChunks; // the total number of chunks in the larger data set
|
||||
uint64 totalNodes; // the total number of nodes that store the data set
|
||||
}
|
||||
|
||||
struct PoR {
|
||||
|
|
|
@ -50,7 +50,7 @@ describe("Marketplace", function () {
|
|||
|
||||
slot = {
|
||||
request: requestId(request),
|
||||
index: request.content.erasure.totalNodes / 2,
|
||||
index: request.ask.slots / 2,
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -169,7 +169,7 @@ describe("Marketplace", function () {
|
|||
})
|
||||
|
||||
it("is rejected when slot index not in range", async function () {
|
||||
const invalid = request.content.erasure.totalNodes
|
||||
const invalid = request.ask.slots
|
||||
await expect(
|
||||
marketplace.fillSlot(slot.request, invalid, proof)
|
||||
).to.be.revertedWith("Invalid slot")
|
||||
|
@ -242,7 +242,7 @@ describe("Marketplace", function () {
|
|||
})
|
||||
|
||||
it("emits event when all slots are filled", async function () {
|
||||
const lastSlot = request.content.erasure.totalNodes - 1
|
||||
const lastSlot = request.ask.slots - 1
|
||||
for (let i = 0; i < lastSlot; i++) {
|
||||
await marketplace.fillSlot(slot.request, i, proof)
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ describe("Storage", function () {
|
|||
request.client = client.address
|
||||
slot = {
|
||||
request: requestId(request),
|
||||
index: request.content.erasure.totalNodes / 2,
|
||||
index: request.ask.slots / 2,
|
||||
}
|
||||
|
||||
switchAccount(client)
|
||||
|
|
|
@ -9,12 +9,12 @@ const exampleRequest = () => ({
|
|||
duration: hours(10),
|
||||
proofProbability: 4, // require a proof roughly once every 4 periods
|
||||
reward: 84,
|
||||
slots: 4,
|
||||
},
|
||||
content: {
|
||||
cid: "zb2rhheVmk3bLks5MgzTqyznLu1zqGH5jrfTA1eAZXrjx7Vob",
|
||||
erasure: {
|
||||
totalChunks: 12,
|
||||
totalNodes: 4,
|
||||
},
|
||||
por: {
|
||||
u: Array.from(randomBytes(480)),
|
||||
|
|
|
@ -2,8 +2,8 @@ const { ethers } = require("hardhat")
|
|||
const { keccak256, defaultAbiCoder } = ethers.utils
|
||||
|
||||
function requestId(request) {
|
||||
const Ask = "tuple(uint256, uint256, uint256, uint256)"
|
||||
const Erasure = "tuple(uint64, uint64)"
|
||||
const Ask = "tuple(uint256, uint256, uint256, uint256, int64)"
|
||||
const Erasure = "tuple(uint64)"
|
||||
const PoR = "tuple(bytes, bytes, bytes)"
|
||||
const Content = "tuple(string, " + Erasure + ", " + PoR + ")"
|
||||
const Request =
|
||||
|
@ -12,11 +12,11 @@ function requestId(request) {
|
|||
}
|
||||
|
||||
function askToArray(ask) {
|
||||
return [ask.size, ask.duration, ask.proofProbability, ask.reward]
|
||||
return [ask.size, ask.duration, ask.proofProbability, ask.reward, ask.slots]
|
||||
}
|
||||
|
||||
function erasureToArray(erasure) {
|
||||
return [erasure.totalChunks, erasure.totalNodes]
|
||||
return [erasure.totalChunks]
|
||||
}
|
||||
|
||||
function porToArray(por) {
|
||||
|
|
Loading…
Reference in New Issue