fixing miner logic to make more tests pass
This commit is contained in:
parent
c45a376dd6
commit
47901c3fb7
@ -46,13 +46,15 @@ func (evt SectorForceState) applyGlobal(state *SectorInfo) bool {
|
||||
// Normal path
|
||||
|
||||
type SectorStart struct {
|
||||
id abi.SectorNumber
|
||||
pieces []Piece
|
||||
id abi.SectorNumber
|
||||
sectorType abi.RegisteredProof
|
||||
pieces []Piece
|
||||
}
|
||||
|
||||
func (evt SectorStart) apply(state *SectorInfo) {
|
||||
state.SectorID = evt.id
|
||||
state.Pieces = evt.pieces
|
||||
state.SectorType = evt.sectorType
|
||||
}
|
||||
|
||||
type SectorPacked struct{ pieces []Piece }
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/lib/nullreader"
|
||||
)
|
||||
|
||||
@ -48,6 +49,12 @@ func (m *Sealing) PledgeSector() error {
|
||||
|
||||
size := abi.PaddedPieceSize(m.sb.SectorSize()).Unpadded()
|
||||
|
||||
rt, _, err := api.ProofTypeFromSectorSize(m.sb.SectorSize())
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
sid, err := m.sb.AcquireSectorNumber()
|
||||
if err != nil {
|
||||
log.Errorf("%+v", err)
|
||||
@ -60,7 +67,7 @@ func (m *Sealing) PledgeSector() error {
|
||||
return
|
||||
}
|
||||
|
||||
if err := m.newSector(sid, pieces); err != nil {
|
||||
if err := m.newSector(sid, rt, pieces); err != nil {
|
||||
log.Errorf("%+v", err)
|
||||
return
|
||||
}
|
||||
|
14
sealing.go
14
sealing.go
@ -121,7 +121,12 @@ func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r i
|
||||
return xerrors.Errorf("adding piece to sector: %w", err)
|
||||
}
|
||||
|
||||
return m.newSector(sectorID, []Piece{
|
||||
rt, _, err := api.ProofTypeFromSectorSize(m.sb.SectorSize())
|
||||
if err != nil {
|
||||
return xerrors.Errorf("bad sector size: %w", err)
|
||||
}
|
||||
|
||||
return m.newSector(sectorID, rt, []Piece{
|
||||
{
|
||||
DealID: &dealID,
|
||||
|
||||
@ -131,10 +136,11 @@ func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r i
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Sealing) newSector(sid abi.SectorNumber, pieces []Piece) error {
|
||||
func (m *Sealing) newSector(sid abi.SectorNumber, rt abi.RegisteredProof, pieces []Piece) error {
|
||||
log.Infof("Start sealing %d", sid)
|
||||
return m.sectors.Send(uint64(sid), SectorStart{
|
||||
id: sid,
|
||||
pieces: pieces,
|
||||
id: sid,
|
||||
pieces: pieces,
|
||||
sectorType: rt,
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user