Skip to content

Commit

Permalink
deal label fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr committed Nov 4, 2024
1 parent ad00bf4 commit 25824fb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/migrate-curio/migrate.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"bytes"
"database/sql"
"encoding/json"
"errors"
Expand Down Expand Up @@ -266,18 +267,27 @@ func migrateBoostDeals(ctx context.Context, activeSectors bitfield.BitField, mad
return fmt.Errorf("deal: %s: failed to marshal headers: %s", deal.DealUuid.String(), err)
}

// Cbor marshal the Deal Label manually as non-string label will result in "" with JSON marshal
label := prop.Label
buf := new(bytes.Buffer)
err = label.MarshalCBOR(buf)
if err != nil {
return fmt.Errorf("cbor marshal label: %w", err)

}

_, err = hdb.BeginTransaction(ctx, func(tx *harmonydb.Tx) (bool, error) {
// Add deal to HarmonyDB
if !a {
_, err = tx.Exec(`INSERT INTO market_mk12_deals (uuid, sp_id, signed_proposal_cid,
proposal_signature, proposal, piece_cid,
piece_size, offline, verified, start_epoch, end_epoch,
client_peer_id, fast_retrieval, announce_to_ipni, url, url_headers, chain_deal_id, publish_cid, created_at)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)
client_peer_id, fast_retrieval, announce_to_ipni, url, url_headers, chain_deal_id, publish_cid, created_at, label)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20)
ON CONFLICT (uuid) DO NOTHING`,
deal.DealUuid.String(), mid, sProp.String(), sigByte, propJson, prop.PieceCID.String(),
prop.PieceSize, deal.IsOffline, prop.VerifiedDeal, prop.StartEpoch, prop.EndEpoch, deal.ClientPeerID.String(),
deal.FastRetrieval, deal.AnnounceToIPNI, tInfo.URL, headers, int64(deal.ChainDealID), deal.PublishCID.String(), deal.CreatedAt)
deal.FastRetrieval, deal.AnnounceToIPNI, tInfo.URL, headers, int64(deal.ChainDealID), deal.PublishCID.String(), deal.CreatedAt, buf.Bytes())

if err != nil {
return false, fmt.Errorf("deal: %s: failed to add the deal to harmonyDB: %w", deal.DealUuid.String(), err)
Expand Down

0 comments on commit 25824fb

Please sign in to comment.