renaming PieceWithOptionalDealInfo -> Piece, drop PieceWithDealInfo
This commit is contained in:
parent
5f3990d1bc
commit
0cd4e0413f
36
cbor_gen.go
36
cbor_gen.go
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
var _ = xerrors.Errorf
|
var _ = xerrors.Errorf
|
||||||
|
|
||||||
func (t *PieceWithOptionalDealInfo) MarshalCBOR(w io.Writer) error {
|
func (t *Piece) MarshalCBOR(w io.Writer) error {
|
||||||
if t == nil {
|
if t == nil {
|
||||||
_, err := w.Write(cbg.CborNull)
|
_, err := w.Write(cbg.CborNull)
|
||||||
return err
|
return err
|
||||||
@ -56,7 +56,7 @@ func (t *PieceWithOptionalDealInfo) MarshalCBOR(w io.Writer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *PieceWithOptionalDealInfo) UnmarshalCBOR(r io.Reader) error {
|
func (t *Piece) UnmarshalCBOR(r io.Reader) error {
|
||||||
br := cbg.GetPeeker(r)
|
br := cbg.GetPeeker(r)
|
||||||
|
|
||||||
maj, extra, err := cbg.CborReadHeader(br)
|
maj, extra, err := cbg.CborReadHeader(br)
|
||||||
@ -68,7 +68,7 @@ func (t *PieceWithOptionalDealInfo) UnmarshalCBOR(r io.Reader) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if extra > cbg.MaxLength {
|
if extra > cbg.MaxLength {
|
||||||
return fmt.Errorf("PieceWithOptionalDealInfo: map struct too large (%d)", extra)
|
return fmt.Errorf("Piece: map struct too large (%d)", extra)
|
||||||
}
|
}
|
||||||
|
|
||||||
var name string
|
var name string
|
||||||
@ -463,26 +463,26 @@ func (t *SectorInfo) MarshalCBOR(w io.Writer) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.PiecesWithOptionalDealInfo ([]sealing.PieceWithOptionalDealInfo) (slice)
|
// t.Pieces ([]sealing.Piece) (slice)
|
||||||
if len("PiecesWithOptionalDealInfo") > cbg.MaxLength {
|
if len("Pieces") > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Value in field \"PiecesWithOptionalDealInfo\" was too long")
|
return xerrors.Errorf("Value in field \"Pieces\" was too long")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("PiecesWithOptionalDealInfo")))); err != nil {
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajTextString, uint64(len("Pieces")))); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err := w.Write([]byte("PiecesWithOptionalDealInfo")); err != nil {
|
if _, err := w.Write([]byte("Pieces")); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(t.PiecesWithOptionalDealInfo) > cbg.MaxLength {
|
if len(t.Pieces) > cbg.MaxLength {
|
||||||
return xerrors.Errorf("Slice value in field t.PiecesWithOptionalDealInfo was too long")
|
return xerrors.Errorf("Slice value in field t.Pieces was too long")
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.PiecesWithOptionalDealInfo)))); err != nil {
|
if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajArray, uint64(len(t.Pieces)))); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, v := range t.PiecesWithOptionalDealInfo {
|
for _, v := range t.Pieces {
|
||||||
if err := v.MarshalCBOR(w); err != nil {
|
if err := v.MarshalCBOR(w); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -897,8 +897,8 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
|||||||
|
|
||||||
t.SectorType = abi.RegisteredProof(extraI)
|
t.SectorType = abi.RegisteredProof(extraI)
|
||||||
}
|
}
|
||||||
// t.PiecesWithOptionalDealInfo ([]sealing.PieceWithOptionalDealInfo) (slice)
|
// t.Pieces ([]sealing.Piece) (slice)
|
||||||
case "PiecesWithOptionalDealInfo":
|
case "Pieces":
|
||||||
|
|
||||||
maj, extra, err = cbg.CborReadHeader(br)
|
maj, extra, err = cbg.CborReadHeader(br)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -906,23 +906,23 @@ func (t *SectorInfo) UnmarshalCBOR(r io.Reader) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if extra > cbg.MaxLength {
|
if extra > cbg.MaxLength {
|
||||||
return fmt.Errorf("t.PiecesWithOptionalDealInfo: array too large (%d)", extra)
|
return fmt.Errorf("t.Pieces: array too large (%d)", extra)
|
||||||
}
|
}
|
||||||
|
|
||||||
if maj != cbg.MajArray {
|
if maj != cbg.MajArray {
|
||||||
return fmt.Errorf("expected cbor array")
|
return fmt.Errorf("expected cbor array")
|
||||||
}
|
}
|
||||||
if extra > 0 {
|
if extra > 0 {
|
||||||
t.PiecesWithOptionalDealInfo = make([]PieceWithOptionalDealInfo, extra)
|
t.Pieces = make([]Piece, extra)
|
||||||
}
|
}
|
||||||
for i := 0; i < int(extra); i++ {
|
for i := 0; i < int(extra); i++ {
|
||||||
|
|
||||||
var v PieceWithOptionalDealInfo
|
var v Piece
|
||||||
if err := v.UnmarshalCBOR(br); err != nil {
|
if err := v.UnmarshalCBOR(br); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
t.PiecesWithOptionalDealInfo[i] = v
|
t.Pieces[i] = v
|
||||||
}
|
}
|
||||||
|
|
||||||
// t.TicketValue (abi.SealRandomness) (slice)
|
// t.TicketValue (abi.SealRandomness) (slice)
|
||||||
|
@ -33,7 +33,7 @@ func checkPieces(ctx context.Context, si SectorInfo, api SealingAPI) error {
|
|||||||
return &ErrApi{xerrors.Errorf("getting chain head: %w", err)}
|
return &ErrApi{xerrors.Errorf("getting chain head: %w", err)}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, pdi := range si.PiecesWithOptionalDealInfo {
|
for i, pdi := range si.Pieces {
|
||||||
// if no deal is associated with the piece, ensure that we added it as
|
// if no deal is associated with the piece, ensure that we added it as
|
||||||
// filler (i.e. ensure that it has a zero PieceCID)
|
// filler (i.e. ensure that it has a zero PieceCID)
|
||||||
if pdi.DealInfo == nil {
|
if pdi.DealInfo == nil {
|
||||||
@ -50,15 +50,15 @@ func checkPieces(ctx context.Context, si SectorInfo, api SealingAPI) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if proposal.PieceCID != pdi.Piece.PieceCID {
|
if proposal.PieceCID != pdi.Piece.PieceCID {
|
||||||
return &ErrInvalidDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers deal %d with wrong PieceCID: %x != %x", i, len(si.PiecesWithOptionalDealInfo), si.SectorNumber, pdi.DealInfo.DealID, pdi.Piece.PieceCID, proposal.PieceCID)}
|
return &ErrInvalidDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers deal %d with wrong PieceCID: %x != %x", i, len(si.Pieces), si.SectorNumber, pdi.DealInfo.DealID, pdi.Piece.PieceCID, proposal.PieceCID)}
|
||||||
}
|
}
|
||||||
|
|
||||||
if pdi.Piece.Size != proposal.PieceSize {
|
if pdi.Piece.Size != proposal.PieceSize {
|
||||||
return &ErrInvalidDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers deal %d with different size: %d != %d", i, len(si.PiecesWithOptionalDealInfo), si.SectorNumber, pdi.DealInfo.DealID, pdi.Piece.Size, proposal.PieceSize)}
|
return &ErrInvalidDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers deal %d with different size: %d != %d", i, len(si.Pieces), si.SectorNumber, pdi.DealInfo.DealID, pdi.Piece.Size, proposal.PieceSize)}
|
||||||
}
|
}
|
||||||
|
|
||||||
if height >= proposal.StartEpoch {
|
if height >= proposal.StartEpoch {
|
||||||
return &ErrExpiredDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers expired deal %d - should start at %d, head %d", i, len(si.PiecesWithOptionalDealInfo), si.SectorNumber, pdi.DealInfo.DealID, proposal.StartEpoch, height)}
|
return &ErrExpiredDeals{xerrors.Errorf("piece %d (of %d) of sector %d refers expired deal %d - should start at %d, head %d", i, len(si.Pieces), si.SectorNumber, pdi.DealInfo.DealID, proposal.StartEpoch, height)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,12 +50,12 @@ func (evt SectorForceState) applyGlobal(state *SectorInfo) bool {
|
|||||||
type SectorStart struct {
|
type SectorStart struct {
|
||||||
ID abi.SectorNumber
|
ID abi.SectorNumber
|
||||||
SectorType abi.RegisteredProof
|
SectorType abi.RegisteredProof
|
||||||
Pieces []PieceWithOptionalDealInfo
|
Pieces []Piece
|
||||||
}
|
}
|
||||||
|
|
||||||
func (evt SectorStart) apply(state *SectorInfo) {
|
func (evt SectorStart) apply(state *SectorInfo) {
|
||||||
state.SectorNumber = evt.ID
|
state.SectorNumber = evt.ID
|
||||||
state.PiecesWithOptionalDealInfo = evt.Pieces
|
state.Pieces = evt.Pieces
|
||||||
state.SectorType = evt.SectorType
|
state.SectorType = evt.SectorType
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ type SectorPacked struct{ FillerPieces []abi.PieceInfo }
|
|||||||
|
|
||||||
func (evt SectorPacked) apply(state *SectorInfo) {
|
func (evt SectorPacked) apply(state *SectorInfo) {
|
||||||
for idx := range evt.FillerPieces {
|
for idx := range evt.FillerPieces {
|
||||||
state.PiecesWithOptionalDealInfo = append(state.PiecesWithOptionalDealInfo, PieceWithOptionalDealInfo{
|
state.Pieces = append(state.Pieces, Piece{
|
||||||
Piece: evt.FillerPieces[idx],
|
Piece: evt.FillerPieces[idx],
|
||||||
DealInfo: nil, // filler pieces don't have deals associated with them
|
DealInfo: nil, // filler pieces don't have deals associated with them
|
||||||
})
|
})
|
||||||
|
@ -69,9 +69,9 @@ func (m *Sealing) PledgeSector() error {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pdis := make([]PieceWithOptionalDealInfo, len(pieces))
|
pdis := make([]Piece, len(pieces))
|
||||||
for idx := range pdis {
|
for idx := range pdis {
|
||||||
pdis[idx] = PieceWithOptionalDealInfo{
|
pdis[idx] = Piece{
|
||||||
Piece: pieces[idx],
|
Piece: pieces[idx],
|
||||||
DealInfo: nil,
|
DealInfo: nil,
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
err := gen.WriteMapEncodersToFile("./cbor_gen.go", "sealing",
|
err := gen.WriteMapEncodersToFile("./cbor_gen.go", "sealing",
|
||||||
sealing.PieceWithOptionalDealInfo{},
|
sealing.Piece{},
|
||||||
sealing.DealInfo{},
|
sealing.DealInfo{},
|
||||||
sealing.DealSchedule{},
|
sealing.DealSchedule{},
|
||||||
sealing.SectorInfo{},
|
sealing.SectorInfo{},
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type PreCommitPolicy interface {
|
type PreCommitPolicy interface {
|
||||||
Expiration(ctx context.Context, pdis ...PieceWithOptionalDealInfo) (abi.ChainEpoch, error)
|
Expiration(ctx context.Context, pdis ...Piece) (abi.ChainEpoch, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Chain interface {
|
type Chain interface {
|
||||||
@ -44,7 +44,7 @@ func NewBasicPreCommitPolicy(api Chain, duration abi.ChainEpoch) BasicPreCommitP
|
|||||||
|
|
||||||
// Expiration produces the pre-commit sector expiration epoch for an encoded
|
// Expiration produces the pre-commit sector expiration epoch for an encoded
|
||||||
// replica containing the provided enumeration of pieces and deals.
|
// replica containing the provided enumeration of pieces and deals.
|
||||||
func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, pdis ...PieceWithOptionalDealInfo) (abi.ChainEpoch, error) {
|
func (p *BasicPreCommitPolicy) Expiration(ctx context.Context, pdis ...Piece) (abi.ChainEpoch, error) {
|
||||||
_, epoch, err := p.api.ChainHead(ctx)
|
_, epoch, err := p.api.ChainHead(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil
|
return 0, nil
|
||||||
|
@ -37,7 +37,7 @@ func TestBasicPolicyMostConstrictiveSchedule(t *testing.T) {
|
|||||||
h: abi.ChainEpoch(55),
|
h: abi.ChainEpoch(55),
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
pieces := []sealing.PieceWithOptionalDealInfo{
|
pieces := []sealing.Piece{
|
||||||
{
|
{
|
||||||
Piece: abi.PieceInfo{
|
Piece: abi.PieceInfo{
|
||||||
Size: abi.PaddedPieceSize(1024),
|
Size: abi.PaddedPieceSize(1024),
|
||||||
@ -77,7 +77,7 @@ func TestBasicPolicyIgnoresExistingScheduleIfExpired(t *testing.T) {
|
|||||||
h: abi.ChainEpoch(55),
|
h: abi.ChainEpoch(55),
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
pieces := []sealing.PieceWithOptionalDealInfo{
|
pieces := []sealing.Piece{
|
||||||
{
|
{
|
||||||
Piece: abi.PieceInfo{
|
Piece: abi.PieceInfo{
|
||||||
Size: abi.PaddedPieceSize(1024),
|
Size: abi.PaddedPieceSize(1024),
|
||||||
@ -104,7 +104,7 @@ func TestMissingDealIsIgnored(t *testing.T) {
|
|||||||
h: abi.ChainEpoch(55),
|
h: abi.ChainEpoch(55),
|
||||||
}, 100)
|
}, 100)
|
||||||
|
|
||||||
pieces := []sealing.PieceWithOptionalDealInfo{
|
pieces := []sealing.Piece{
|
||||||
{
|
{
|
||||||
Piece: abi.PieceInfo{
|
Piece: abi.PieceInfo{
|
||||||
Size: abi.PaddedPieceSize(1024),
|
Size: abi.PaddedPieceSize(1024),
|
||||||
|
11
sealing.go
11
sealing.go
@ -35,6 +35,7 @@ type SealingAPI interface {
|
|||||||
SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, gasPrice big.Int, gasLimit int64, params []byte) (cid.Cid, error)
|
SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, gasPrice big.Int, gasLimit int64, params []byte) (cid.Cid, error)
|
||||||
ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error)
|
ChainHead(ctx context.Context) (TipSetToken, abi.ChainEpoch, error)
|
||||||
ChainGetRandomness(ctx context.Context, tok TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
|
ChainGetRandomness(ctx context.Context, tok TipSetToken, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error)
|
||||||
|
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Sealing struct {
|
type Sealing struct {
|
||||||
@ -104,8 +105,8 @@ func (m *Sealing) AllocatePiece(size abi.UnpaddedPieceSize) (sectorID abi.Sector
|
|||||||
return sid, 0, nil
|
return sid, 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, sectorID abi.SectorNumber, pdi PieceWithDealInfo) error {
|
func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r io.Reader, sectorID abi.SectorNumber, d DealInfo) error {
|
||||||
log.Infof("Seal piece for deal %d", pdi.DealInfo.DealID)
|
log.Infof("Seal piece for deal %d", d.DealID)
|
||||||
|
|
||||||
ppi, err := m.sealer.AddPiece(ctx, m.minerSector(sectorID), []abi.UnpaddedPieceSize{}, size, r)
|
ppi, err := m.sealer.AddPiece(ctx, m.minerSector(sectorID), []abi.UnpaddedPieceSize{}, size, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -117,10 +118,10 @@ func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r i
|
|||||||
return xerrors.Errorf("bad sector size: %w", err)
|
return xerrors.Errorf("bad sector size: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return m.newSector(sectorID, rt, []PieceWithOptionalDealInfo{
|
return m.newSector(sectorID, rt, []Piece{
|
||||||
{
|
{
|
||||||
Piece: ppi,
|
Piece: ppi,
|
||||||
DealInfo: &pdi.DealInfo,
|
DealInfo: &d,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -128,7 +129,7 @@ func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r i
|
|||||||
// newSector accepts a slice of pieces which will have a deal associated with
|
// newSector accepts a slice of pieces which will have a deal associated with
|
||||||
// them (in the event of a storage deal) or no deal (in the event of sealing
|
// them (in the event of a storage deal) or no deal (in the event of sealing
|
||||||
// garbage data)
|
// garbage data)
|
||||||
func (m *Sealing) newSector(sid abi.SectorNumber, rt abi.RegisteredProof, pieces []PieceWithOptionalDealInfo) error {
|
func (m *Sealing) newSector(sid abi.SectorNumber, rt abi.RegisteredProof, pieces []Piece) error {
|
||||||
log.Infof("Start sealing %d", sid)
|
log.Infof("Start sealing %d", sid)
|
||||||
return m.sectors.Send(uint64(sid), SectorStart{
|
return m.sectors.Send(uint64(sid), SectorStart{
|
||||||
ID: sid,
|
ID: sid,
|
||||||
|
@ -19,7 +19,7 @@ func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) err
|
|||||||
log.Infow("performing filling up rest of the sector...", "sector", sector.SectorNumber)
|
log.Infow("performing filling up rest of the sector...", "sector", sector.SectorNumber)
|
||||||
|
|
||||||
var allocated abi.UnpaddedPieceSize
|
var allocated abi.UnpaddedPieceSize
|
||||||
for _, piece := range sector.PiecesWithOptionalDealInfo {
|
for _, piece := range sector.Pieces {
|
||||||
allocated += piece.Piece.Size.Unpadded()
|
allocated += piece.Piece.Size.Unpadded()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
expiration, err := m.pcp.Expiration(ctx.Context(), sector.PiecesWithOptionalDealInfo...)
|
expiration, err := m.pcp.Expiration(ctx.Context(), sector.Pieces...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ctx.Send(SectorSealPreCommitFailed{xerrors.Errorf("handlePreCommitting: failed to compute pre-commit expiry: %w", err)})
|
return ctx.Send(SectorSealPreCommitFailed{xerrors.Errorf("handlePreCommitting: failed to compute pre-commit expiry: %w", err)})
|
||||||
}
|
}
|
||||||
|
22
types.go
22
types.go
@ -11,16 +11,16 @@ import (
|
|||||||
"github.com/filecoin-project/specs-storage/storage"
|
"github.com/filecoin-project/specs-storage/storage"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PieceWithOptionalDealInfo is a tuple of piece and deal info
|
// Piece is a tuple of piece and deal info
|
||||||
type PieceWithDealInfo struct {
|
type PieceWithDealInfo struct {
|
||||||
Piece abi.PieceInfo
|
Piece abi.PieceInfo
|
||||||
DealInfo DealInfo
|
DealInfo DealInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
// PieceWithOptionalDealInfo is a tuple of piece info and optional deal
|
// Piece is a tuple of piece info and optional deal
|
||||||
type PieceWithOptionalDealInfo struct {
|
type Piece struct {
|
||||||
Piece abi.PieceInfo
|
Piece abi.PieceInfo
|
||||||
DealInfo *DealInfo // nil for pieces which do not yet appear in self-deals
|
DealInfo *DealInfo // nil for pieces which do not appear in deals (e.g. filler pieces)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DealInfo is a tuple of deal identity and its schedule
|
// DealInfo is a tuple of deal identity and its schedule
|
||||||
@ -55,7 +55,7 @@ type SectorInfo struct {
|
|||||||
SectorType abi.RegisteredProof
|
SectorType abi.RegisteredProof
|
||||||
|
|
||||||
// Packing
|
// Packing
|
||||||
PiecesWithOptionalDealInfo []PieceWithOptionalDealInfo
|
Pieces []Piece
|
||||||
|
|
||||||
// PreCommit1
|
// PreCommit1
|
||||||
TicketValue abi.SealRandomness
|
TicketValue abi.SealRandomness
|
||||||
@ -87,8 +87,8 @@ type SectorInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *SectorInfo) pieceInfos() []abi.PieceInfo {
|
func (t *SectorInfo) pieceInfos() []abi.PieceInfo {
|
||||||
out := make([]abi.PieceInfo, len(t.PiecesWithOptionalDealInfo))
|
out := make([]abi.PieceInfo, len(t.Pieces))
|
||||||
for i, pdi := range t.PiecesWithOptionalDealInfo {
|
for i, pdi := range t.Pieces {
|
||||||
out[i] = abi.PieceInfo{
|
out[i] = abi.PieceInfo{
|
||||||
Size: pdi.Piece.Size,
|
Size: pdi.Piece.Size,
|
||||||
PieceCID: pdi.Piece.PieceCID,
|
PieceCID: pdi.Piece.PieceCID,
|
||||||
@ -98,8 +98,8 @@ func (t *SectorInfo) pieceInfos() []abi.PieceInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *SectorInfo) dealIDs() []abi.DealID {
|
func (t *SectorInfo) dealIDs() []abi.DealID {
|
||||||
out := make([]abi.DealID, 0, len(t.PiecesWithOptionalDealInfo))
|
out := make([]abi.DealID, 0, len(t.Pieces))
|
||||||
for _, pdi := range t.PiecesWithOptionalDealInfo {
|
for _, pdi := range t.Pieces {
|
||||||
if pdi.DealInfo == nil {
|
if pdi.DealInfo == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -109,8 +109,8 @@ func (t *SectorInfo) dealIDs() []abi.DealID {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *SectorInfo) existingPieceSizes() []abi.UnpaddedPieceSize {
|
func (t *SectorInfo) existingPieceSizes() []abi.UnpaddedPieceSize {
|
||||||
out := make([]abi.UnpaddedPieceSize, len(t.PiecesWithOptionalDealInfo))
|
out := make([]abi.UnpaddedPieceSize, len(t.Pieces))
|
||||||
for i, pdi := range t.PiecesWithOptionalDealInfo {
|
for i, pdi := range t.Pieces {
|
||||||
out[i] = pdi.Piece.Size.Unpadded()
|
out[i] = pdi.Piece.Size.Unpadded()
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
|
@ -28,7 +28,7 @@ func TestSectorInfoSelialization(t *testing.T) {
|
|||||||
State: "stateful",
|
State: "stateful",
|
||||||
SectorNumber: 234,
|
SectorNumber: 234,
|
||||||
Nonce: 345,
|
Nonce: 345,
|
||||||
PiecesWithOptionalDealInfo: []PieceWithOptionalDealInfo{{
|
Pieces: []Piece{{
|
||||||
Piece: abi.PieceInfo{
|
Piece: abi.PieceInfo{
|
||||||
Size: 5,
|
Size: 5,
|
||||||
PieceCID: dummyCid,
|
PieceCID: dummyCid,
|
||||||
@ -62,7 +62,7 @@ func TestSectorInfoSelialization(t *testing.T) {
|
|||||||
assert.Equal(t, si.Nonce, si2.Nonce)
|
assert.Equal(t, si.Nonce, si2.Nonce)
|
||||||
assert.Equal(t, si.SectorNumber, si2.SectorNumber)
|
assert.Equal(t, si.SectorNumber, si2.SectorNumber)
|
||||||
|
|
||||||
assert.Equal(t, si.PiecesWithOptionalDealInfo, si2.PiecesWithOptionalDealInfo)
|
assert.Equal(t, si.Pieces, si2.Pieces)
|
||||||
assert.Equal(t, si.CommD, si2.CommD)
|
assert.Equal(t, si.CommD, si2.CommD)
|
||||||
assert.Equal(t, si.TicketValue, si2.TicketValue)
|
assert.Equal(t, si.TicketValue, si2.TicketValue)
|
||||||
assert.Equal(t, si.TicketEpoch, si2.TicketEpoch)
|
assert.Equal(t, si.TicketEpoch, si2.TicketEpoch)
|
||||||
|
Loading…
Reference in New Issue
Block a user