lotus/types.go

103 lines
1.7 KiB
Go
Raw Normal View History

package sealing
import (
"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"
)
type SealTicket struct {
2020-02-12 00:58:55 +00:00
BlockHeight abi.ChainEpoch
2020-02-27 00:42:39 +00:00
TicketBytes abi.SealRandomness
}
type SealSeed struct {
2020-02-08 02:18:32 +00:00
BlockHeight abi.ChainEpoch
2020-02-27 00:42:39 +00:00
TicketBytes abi.InteractiveSealRandomness
}
func (t *SealSeed) Equals(o *SealSeed) bool {
return string(t.TicketBytes) == string(o.TicketBytes) && t.BlockHeight == o.BlockHeight
}
type Piece struct {
2020-02-23 00:47:47 +00:00
DealID *abi.DealID
2020-02-08 02:18:32 +00:00
Size abi.UnpaddedPieceSize
2020-02-27 00:42:39 +00:00
CommP cid.Cid
}
2020-01-22 02:41:39 +00:00
type Log struct {
Timestamp uint64
Trace string // for errors
Message string
// additional data (Event info)
Kind string
2020-01-22 02:41:39 +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-02-27 00:42:39 +00:00
SectorType abi.RegisteredProof
// Packing
Pieces []Piece
// PreCommit
2020-02-27 00:42:39 +00:00
CommD *cid.Cid
CommR *cid.Cid
Proof []byte
Ticket SealTicket
PreCommitMessage *cid.Cid
2020-01-20 22:04:46 +00:00
// WaitSeed
Seed SealSeed
// Committing
CommitMessage *cid.Cid
// Faults
FaultReportMsg *cid.Cid
// Debug
LastErr string
2020-01-22 02:41:39 +00:00
Log []Log
}
2020-02-27 00:42:39 +00:00
func (t *SectorInfo) pieceInfos() []abi.PieceInfo {
out := make([]abi.PieceInfo, len(t.Pieces))
for i, piece := range t.Pieces {
2020-02-27 00:42:39 +00:00
out[i] = abi.PieceInfo{
Size: piece.Size.Padded(),
PieceCID: piece.CommP,
}
}
return out
}
2020-02-08 02:18:32 +00:00
func (t *SectorInfo) deals() []abi.DealID {
2020-02-23 00:47:47 +00:00
out := make([]abi.DealID, 0, len(t.Pieces))
for _, piece := range t.Pieces {
if piece.DealID == nil {
continue
}
out = append(out, *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))
for i, piece := range t.Pieces {
out[i] = piece.Size
}
return out
}