2020-01-15 20:49:11 +00:00
|
|
|
package sealing
|
|
|
|
|
|
|
|
import (
|
|
|
|
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
|
|
|
"github.com/filecoin-project/lotus/api"
|
2020-02-08 02:18:32 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2020-01-22 02:41:39 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2020-01-15 20:49:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type SealTicket struct {
|
|
|
|
BlockHeight uint64
|
|
|
|
TicketBytes []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SealTicket) SB() sectorbuilder.SealTicket {
|
|
|
|
out := sectorbuilder.SealTicket{BlockHeight: t.BlockHeight}
|
|
|
|
copy(out.TicketBytes[:], t.TicketBytes)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
type SealSeed struct {
|
2020-02-08 02:18:32 +00:00
|
|
|
BlockHeight abi.ChainEpoch
|
2020-01-15 20:49:11 +00:00
|
|
|
TicketBytes []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SealSeed) SB() sectorbuilder.SealSeed {
|
2020-02-08 02:18:32 +00:00
|
|
|
out := sectorbuilder.SealSeed{BlockHeight: uint64(t.BlockHeight)}
|
2020-01-15 20:49:11 +00:00
|
|
|
copy(out.TicketBytes[:], t.TicketBytes)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2020-01-16 01:25:49 +00:00
|
|
|
func (t *SealSeed) Equals(o *SealSeed) bool {
|
|
|
|
return string(t.TicketBytes) == string(o.TicketBytes) && t.BlockHeight == o.BlockHeight
|
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
type Piece struct {
|
2020-02-08 02:18:32 +00:00
|
|
|
DealID abi.DealID
|
2020-01-15 20:49:11 +00:00
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
Size abi.UnpaddedPieceSize
|
2020-01-15 20:49:11 +00:00
|
|
|
CommP []byte
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Piece) ppi() (out sectorbuilder.PublicPieceInfo) {
|
2020-02-11 01:10:50 +00:00
|
|
|
out.Size = p.Size
|
2020-01-15 20:49:11 +00:00
|
|
|
copy(out.CommP[:], p.CommP)
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2020-01-22 02:41:39 +00:00
|
|
|
type Log struct {
|
|
|
|
Timestamp uint64
|
|
|
|
Trace string // for errors
|
|
|
|
|
|
|
|
Message string
|
|
|
|
|
|
|
|
// additional data (Event info)
|
2020-01-23 14:18:05 +00:00
|
|
|
Kind string
|
2020-01-22 02:41:39 +00:00
|
|
|
}
|
|
|
|
|
2020-01-15 20:49:11 +00:00
|
|
|
type SectorInfo struct {
|
|
|
|
State api.SectorState
|
2020-02-08 02:18:32 +00:00
|
|
|
SectorID abi.SectorNumber
|
2020-01-20 22:04:46 +00:00
|
|
|
Nonce uint64 // TODO: remove
|
2020-01-15 20:49:11 +00:00
|
|
|
|
|
|
|
// Packing
|
|
|
|
|
|
|
|
Pieces []Piece
|
|
|
|
|
|
|
|
// PreCommit
|
|
|
|
CommD []byte
|
|
|
|
CommR []byte
|
|
|
|
Proof []byte
|
|
|
|
Ticket SealTicket
|
|
|
|
|
|
|
|
PreCommitMessage *cid.Cid
|
|
|
|
|
2020-01-20 22:04:46 +00:00
|
|
|
// WaitSeed
|
2020-01-15 20:49:11 +00:00
|
|
|
Seed SealSeed
|
|
|
|
|
|
|
|
// Committing
|
|
|
|
CommitMessage *cid.Cid
|
|
|
|
|
|
|
|
// Faults
|
|
|
|
FaultReportMsg *cid.Cid
|
|
|
|
|
|
|
|
// Debug
|
|
|
|
LastErr string
|
2020-01-16 01:25:49 +00:00
|
|
|
|
2020-01-22 02:41:39 +00:00
|
|
|
Log []Log
|
2020-01-15 20:49:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SectorInfo) pieceInfos() []sectorbuilder.PublicPieceInfo {
|
|
|
|
out := make([]sectorbuilder.PublicPieceInfo, len(t.Pieces))
|
|
|
|
for i, piece := range t.Pieces {
|
|
|
|
out[i] = piece.ppi()
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
func (t *SectorInfo) deals() []abi.DealID {
|
|
|
|
out := make([]abi.DealID, len(t.Pieces))
|
2020-01-15 20:49:11 +00:00
|
|
|
for i, piece := range t.Pieces {
|
|
|
|
out[i] = piece.DealID
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
2020-02-08 02:18:32 +00:00
|
|
|
func (t *SectorInfo) existingPieces() []abi.UnpaddedPieceSize {
|
|
|
|
out := make([]abi.UnpaddedPieceSize, len(t.Pieces))
|
2020-01-15 20:49:11 +00:00
|
|
|
for i, piece := range t.Pieces {
|
|
|
|
out[i] = piece.Size
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *SectorInfo) rspco() sectorbuilder.RawSealPreCommitOutput {
|
|
|
|
var out sectorbuilder.RawSealPreCommitOutput
|
|
|
|
|
|
|
|
copy(out.CommD[:], t.CommD)
|
|
|
|
copy(out.CommR[:], t.CommR)
|
|
|
|
|
|
|
|
return out
|
|
|
|
}
|