Skip to content

Commit

Permalink
fix offline deal handling
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr committed Jan 13, 2025
1 parent 59c7a4f commit cccfa74
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions market/mk12/mk12.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,24 +424,28 @@ func (m *MK12) processDeal(ctx context.Context, deal *ProviderDealState) (*Provi
}, nil
}

// de-serialize transport opaque token
tInfo := &HttpRequest{}
if err := json.Unmarshal(deal.Transfer.Params, tInfo); err != nil {
return &ProviderDealRejectionInfo{
Reason: fmt.Sprintf("failed to de-serialize transport params bytes '%s': %s", string(deal.Transfer.Params), err),
}, nil
}
var headers []byte
var tInfo *HttpRequest

if !deal.IsOffline {
// de-serialize transport opaque token
if err := json.Unmarshal(deal.Transfer.Params, tInfo); err != nil {
return &ProviderDealRejectionInfo{
Reason: fmt.Sprintf("failed to de-serialize transport params bytes '%s': %s", string(deal.Transfer.Params), err),
}, nil
}

goheaders := http.Header{}
for k, v := range tInfo.Headers {
goheaders.Set(k, v)
}
goheaders := http.Header{}
for k, v := range tInfo.Headers {
goheaders.Set(k, v)
}

headers, err := json.Marshal(goheaders)
if err != nil {
return &ProviderDealRejectionInfo{
Reason: fmt.Sprintf("failed to marshal headers: %s", err),
}, nil
headers, err = json.Marshal(goheaders)
if err != nil {
return &ProviderDealRejectionInfo{
Reason: fmt.Sprintf("failed to marshal headers: %s", err),
}, nil
}
}

// Cbor marshal the Deal Label manually as non-string label will result in "" with JSON marshal
Expand Down

0 comments on commit cccfa74

Please sign in to comment.