mirror of
https://github.com/status-im/dagger-contracts.git
synced 2025-01-09 22:05:50 +00:00
perf: optimizing parameters sizing
This commit is contained in:
parent
dfab6102e7
commit
7e69a3be3e
@ -10,7 +10,7 @@ insert_final_newline = true
|
||||
|
||||
# Matches multiple files with brace expansion notation
|
||||
# Set default charset
|
||||
[{*.js, *.sol}]
|
||||
[{*.js,*.sol}]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
@ -8,17 +8,17 @@ struct Request {
|
||||
address client;
|
||||
Ask ask;
|
||||
Content content;
|
||||
uint256 expiry; // amount of seconds since start of the request at which this request expires
|
||||
uint64 expiry; // amount of seconds since start of the request at which this request expires
|
||||
bytes32 nonce; // random nonce to differentiate between similar requests
|
||||
}
|
||||
|
||||
struct Ask {
|
||||
uint64 slots; // the number of requested slots
|
||||
uint256 slotSize; // amount of storage per slot (in number of bytes)
|
||||
uint256 duration; // how long content should be stored (in seconds)
|
||||
uint256 proofProbability; // how often storage proofs are required
|
||||
uint256 reward; // amount of tokens paid per second per slot to hosts
|
||||
uint256 collateral; // amount of tokens required to be deposited by the hosts in order to fill the slot
|
||||
uint64 slots; // the number of requested slots
|
||||
uint64 slotSize; // amount of storage per slot (in number of bytes)
|
||||
uint64 duration; // how long content should be stored (in seconds)
|
||||
uint64 maxSlotLoss; // Max slots that can be lost without data considered to be lost
|
||||
}
|
||||
|
||||
|
11
test/ids.js
11
test/ids.js
@ -2,21 +2,20 @@ const { ethers } = require("hardhat")
|
||||
const { keccak256, defaultAbiCoder } = ethers.utils
|
||||
|
||||
function requestId(request) {
|
||||
const Ask = "tuple(int64, uint256, uint256, uint256, uint256, uint256, int64)"
|
||||
const Ask = "tuple(uint256, uint256, uint256, int64, int64, int64, int64)"
|
||||
const Content = "tuple(string, bytes32)"
|
||||
const Request =
|
||||
"tuple(address, " + Ask + ", " + Content + ", uint256, bytes32)"
|
||||
const Request = "tuple(address, " + Ask + ", " + Content + ", int64, bytes32)"
|
||||
return keccak256(defaultAbiCoder.encode([Request], requestToArray(request)))
|
||||
}
|
||||
|
||||
function askToArray(ask) {
|
||||
return [
|
||||
ask.slots,
|
||||
ask.slotSize,
|
||||
ask.duration,
|
||||
ask.proofProbability,
|
||||
ask.reward,
|
||||
ask.collateral,
|
||||
ask.slots,
|
||||
ask.slotSize,
|
||||
ask.duration,
|
||||
ask.maxSlotLoss,
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user