Skip to content

Commit

Permalink
Adds basic BackupItem struct to contract
Browse files Browse the repository at this point in the history
  • Loading branch information
ottpeter committed Mar 31, 2023
1 parent 02cc11b commit 4e0dd7c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
3 changes: 2 additions & 1 deletion backend/utils/backupUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const backupObj = {
carExportReady: false,
commPCalculationReady: false,
dealRequestMade: false,
dealPublished: false,
dealAccepted: false,
dealActive: false
};
Expand Down Expand Up @@ -252,7 +253,7 @@ async function checkDealStatus(folderName) {
dealID = result.toNumber();
console.log("Deal ID: ", dealID);
if (dealID !== 0) {
inProgressBackups[folderName].dealAccepted = true;
inProgressBackups[folderName].dealPublished = true;
break;
}
try_count++;
Expand Down
31 changes: 26 additions & 5 deletions contracts/basic-deal-client/DealClient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,25 @@ struct ExtraParamsV1 {
bool remove_unsealed_copy;
}

// For every PieceCID, we will store this collection of data
// It will be a value pair of a commP key
struct BackupItem {
uint16 totalDealCount;
uint16 atLeast1MonthDealCount;
uint16 targetRedundancy;
BackupItemDeal[] deals;
}

// A single deal about a BackupItem
struct BackupItemDeal {
uint64 dealId;
bytes providerAddress;
int64 startEpoch;
int64 endEpoch;
MarketTypes.GetDealActivationReturn status;
bool isActivated;
}

function serializeExtraParamsV1(ExtraParamsV1 memory params) pure returns (bytes memory) {
CBOR.CBORBuffer memory buf = CBOR.create(64);
buf.startFixedArray(4);
Expand All @@ -91,13 +110,15 @@ contract DealClient {
uint64 constant public DATACAP_RECEIVER_HOOK_METHOD_NUM = 3726118371;
uint64 constant public MARKET_NOTIFY_DEAL_METHOD_NUM = 4186741094;

mapping(bytes32 => ProposalIdx) public dealProposals; // contract deal id -> deal index
mapping(bytes => ProposalIdSet) public pieceToProposal; // commP -> dealProposalID
mapping(bytes => ProviderSet) public pieceProviders; // commP -> provider
mapping(bytes => uint64) public pieceDeals; // commP -> deal ID
mapping(bytes32 => ProposalIdx) public dealProposals; // contract deal id -> deal index
mapping(bytes => ProposalIdSet) public pieceToProposal; // commP -> dealProposalID
mapping(bytes => ProviderSet) public pieceProviders; // commP -> provider
mapping(bytes => uint64) public pieceDeals; // commP -> deal ID
mapping(bytes => BackupItem) public backupItems; // commP -> BackupItem - this is the one that we will keep on the long run

DealRequest[] deals;

// Temporary variables
// Temporary variables - this will become obsolate
MarketTypes.GetDealActivationReturn public tempActivationStatus;
bool public tempIsDealActivated;

Expand Down

0 comments on commit 4e0dd7c

Please sign in to comment.