Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update json of delta deal response to match #41

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions core/delta-rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ func (r *OfflineDealResponse) Marshal() ([]byte, error) {
}

type OfflineDealResponseElement struct {
Status string `json:"status"`
Message string `json:"message"`
ContentID int64 `json:"content_id"`
PieceCommitmentID int64 `json:"piece_commitment_id"`
RequestMeta Deal `json:"request_meta"`
Status string `json:"status"`
Message string `json:"message"`
DeltaContentID int64 `json:"content_id"`
PieceCommitmentID int64 `json:"piece_commitment_id"`
DealRequestMeta Deal `json:"deal_request_meta"`
DealProposalParameterRequestMeta ParamRequestMeta `json:"deal_proposal_parameter_request_meta"`
}

type Deal struct { // AKA meta
DeltaContentID uint64 `json:"content_id,omitempty"` // TODO: rename to delta_id
Cid string `json:"cid"`
Wallet Wallet `json:"wallet"`
Miner string `json:"miner"` //TODO: rename to provider
Expand All @@ -308,6 +308,16 @@ type Deal struct { // AKA meta
StartEpochAtDays uint64 `json:"start_epoch_at_days,omitempty"`
}

type ParamRequestMeta struct {
ID uint64 `json:"ID"`
Content uint64 `json:"content"`
Label string `json:"label"`
Duration uint64 `json:"duration"`
RemoveUnsealedCopy bool `json:"remove_unsealed_copy"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}

type PieceCommitment struct {
PieceCid string `json:"piece_cid"`
PaddedPieceSize uint64 `json:"padded_piece_size"`
Expand Down
5 changes: 4 additions & 1 deletion core/delta-watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ func RunReconciliation(db *gorm.DB, d *DeltaAPI) error {
if err.Error != nil {
return fmt.Errorf("could not find associated content: %s", err.Error)
}
cnt.NumReplications -= 1
// This condition should always be true, but just in case
if cnt.NumReplications > 0 {
cnt.NumReplications -= 1
}

err = db.Save(&cnt)
if err.Error != nil {
Expand Down
6 changes: 3 additions & 3 deletions core/make-deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func (dldm *DeltaDM) MakeDeals(dealsToMake OfflineDealRequest, authKey string, i
continue
}
var newReplication = Replication{
ContentCommP: c.RequestMeta.PieceCommitment.PieceCid,
ProviderActorID: c.RequestMeta.Miner,
DeltaContentID: c.ContentID,
ContentCommP: c.DealRequestMeta.PieceCommitment.PieceCid,
ProviderActorID: c.DealRequestMeta.Miner,
DeltaContentID: c.DeltaContentID,
DealTime: time.Now(),
Status: StatusPending,
IsSelfService: isSelfService,
Expand Down