lotus/types.go

123 lines
2.3 KiB
Go
Raw Normal View History

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"
)
type SealTicket struct {
2020-02-12 00:58:55 +00:00
BlockHeight abi.ChainEpoch
TicketBytes []byte
}
func (t *SealTicket) SB() sectorbuilder.SealTicket {
2020-02-12 00:58:55 +00:00
out := sectorbuilder.SealTicket{BlockHeight: uint64(t.BlockHeight)}
copy(out.TicketBytes[:], t.TicketBytes)
return out
}
type SealSeed struct {
2020-02-08 02:18:32 +00:00
BlockHeight abi.ChainEpoch
TicketBytes []byte
}
func (t *SealSeed) SB() sectorbuilder.SealSeed {
2020-02-08 02:18:32 +00:00
out := sectorbuilder.SealSeed{BlockHeight: uint64(t.BlockHeight)}
copy(out.TicketBytes[:], t.TicketBytes)
return out
}
func (t *SealSeed) Equals(o *SealSeed) bool {
return string(t.TicketBytes) == string(o.TicketBytes) && t.BlockHeight == o.BlockHeight
}
type Piece struct {
2020-02-08 02:18:32 +00:00
DealID abi.DealID
2020-02-08 02:18:32 +00:00
Size abi.UnpaddedPieceSize
CommP []byte
}
func (p *Piece) ppi() (out sectorbuilder.PublicPieceInfo) {
2020-02-11 01:10:50 +00:00
out.Size = p.Size
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)
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
// Packing
Pieces []Piece
// PreCommit
CommD []byte
CommR []byte
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
}
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))
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))
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
}