on chain deals: use cid bytes for PieceRef
This commit is contained in:
parent
6bade2eb23
commit
7420dd668e
@ -60,7 +60,7 @@ type StorageMarketState struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StorageDealProposal struct {
|
type StorageDealProposal struct {
|
||||||
PieceRef cid.Cid // can this mess anything up? Should this just be cid bytes
|
PieceRef []byte // cid bytes // TODO: spec says to use cid.Cid, probably not a good idea
|
||||||
PieceSize uint64
|
PieceSize uint64
|
||||||
Client address.Address
|
Client address.Address
|
||||||
Provider address.Address
|
Provider address.Address
|
||||||
|
@ -3058,10 +3058,12 @@ func (t *StorageDealProposal) MarshalCBOR(w io.Writer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.t.PieceRef (cid.Cid)
|
// t.t.PieceRef ([]uint8)
|
||||||
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajByteString, uint64(len(t.PieceRef)))); err != nil {
|
||||||
if err := cbg.WriteCid(w, t.PieceRef); err != nil {
|
return err
|
||||||
return xerrors.Errorf("failed to write cid field t.PieceRef: %w", err)
|
}
|
||||||
|
if _, err := w.Write(t.PieceRef); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.t.PieceSize (uint64)
|
// t.t.PieceSize (uint64)
|
||||||
@ -3121,17 +3123,22 @@ func (t *StorageDealProposal) UnmarshalCBOR(r io.Reader) error {
|
|||||||
return fmt.Errorf("cbor input had wrong number of fields")
|
return fmt.Errorf("cbor input had wrong number of fields")
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.t.PieceRef (cid.Cid)
|
// t.t.PieceRef ([]uint8)
|
||||||
|
|
||||||
{
|
maj, extra, err = cbg.CborReadHeader(br)
|
||||||
|
|
||||||
c, err := cbg.ReadCid(br)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("failed to read cid field t.PieceRef: %w", err)
|
return err
|
||||||
|
}
|
||||||
|
if extra > 8192 {
|
||||||
|
return fmt.Errorf("t.PieceRef: array too large (%d)", extra)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.PieceRef = c
|
if maj != cbg.MajByteString {
|
||||||
|
return fmt.Errorf("expected byte array")
|
||||||
|
}
|
||||||
|
t.PieceRef = make([]byte, extra)
|
||||||
|
if _, err := io.ReadFull(br, t.PieceRef); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
// t.t.PieceSize (uint64)
|
// t.t.PieceSize (uint64)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user