sealing: gofmt
This commit is contained in:
parent
cc424d64fe
commit
d4c50b8ea0
@ -41,8 +41,8 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/modules/helpers"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
"github.com/filecoin-project/lotus/storage/sealing"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
)
|
||||
|
||||
func minerAddrFromDS(ds dtypes.MetadataDS) (address.Address, error) {
|
||||
|
@ -36,8 +36,8 @@ type Miner struct {
|
||||
|
||||
sealing *sealing.Sealing
|
||||
|
||||
stop chan struct{}
|
||||
stopped chan struct{}
|
||||
stop chan struct{}
|
||||
stopped chan struct{}
|
||||
}
|
||||
|
||||
type storageMinerApi interface {
|
||||
@ -67,16 +67,16 @@ type storageMinerApi interface {
|
||||
|
||||
func NewMiner(api storageMinerApi, addr address.Address, h host.Host, ds datastore.Batching, sb sectorbuilder.Interface, tktFn sealing.TicketFn) (*Miner, error) {
|
||||
m := &Miner{
|
||||
api: api,
|
||||
api: api,
|
||||
h: h,
|
||||
sb: sb,
|
||||
ds: ds,
|
||||
ds: ds,
|
||||
tktFn: tktFn,
|
||||
|
||||
maddr: addr,
|
||||
|
||||
stop: make(chan struct{}),
|
||||
stopped: make(chan struct{}),
|
||||
stop: make(chan struct{}),
|
||||
stopped: make(chan struct{}),
|
||||
}
|
||||
|
||||
return m, nil
|
||||
@ -88,8 +88,8 @@ func (m *Miner) Run(ctx context.Context) error {
|
||||
}
|
||||
|
||||
fps := &fpostScheduler{
|
||||
api: m.api,
|
||||
sb: m.sb,
|
||||
api: m.api,
|
||||
sb: m.sb,
|
||||
|
||||
actor: m.maddr,
|
||||
worker: m.worker,
|
||||
|
@ -28,9 +28,9 @@ func (m *Sealing) Plan(events []statemachine.Event, user interface{}) (interface
|
||||
}, nil
|
||||
}
|
||||
|
||||
var fsmPlanners = []func(events []statemachine.Event, state *SectorInfo) error {
|
||||
var fsmPlanners = []func(events []statemachine.Event, state *SectorInfo) error{
|
||||
api.UndefinedSectorState: planOne(on(SectorStart{}, api.Packing)),
|
||||
api.Packing: planOne(on(SectorPacked{}, api.Unsealed)),
|
||||
api.Packing: planOne(on(SectorPacked{}, api.Unsealed)),
|
||||
api.Unsealed: planOne(
|
||||
on(SectorSealed{}, api.PreCommitting),
|
||||
on(SectorSealFailed{}, api.SealFailed),
|
||||
|
@ -19,9 +19,11 @@ type globalMutator interface {
|
||||
// Global events
|
||||
|
||||
type SectorRestart struct{}
|
||||
|
||||
func (evt SectorRestart) applyGlobal(*SectorInfo) bool { return false }
|
||||
|
||||
type SectorFatalError struct{ error }
|
||||
|
||||
func (evt SectorFatalError) applyGlobal(state *SectorInfo) bool {
|
||||
log.Errorf("Fatal error on sector %d: %+v", state.SectorID, evt.error)
|
||||
// TODO: Do we want to mark the state as unrecoverable?
|
||||
@ -33,6 +35,7 @@ func (evt SectorFatalError) applyGlobal(state *SectorInfo) bool {
|
||||
type SectorForceState struct {
|
||||
state api.SectorState
|
||||
}
|
||||
|
||||
func (evt SectorForceState) applyGlobal(state *SectorInfo) bool {
|
||||
state.State = evt.state
|
||||
return true
|
||||
@ -44,12 +47,14 @@ type SectorStart struct {
|
||||
id uint64
|
||||
pieces []Piece
|
||||
}
|
||||
|
||||
func (evt SectorStart) apply(state *SectorInfo) {
|
||||
state.SectorID = evt.id
|
||||
state.Pieces = evt.pieces
|
||||
}
|
||||
|
||||
type SectorPacked struct{ pieces []Piece }
|
||||
|
||||
func (evt SectorPacked) apply(state *SectorInfo) {
|
||||
state.Pieces = append(state.Pieces, evt.pieces...)
|
||||
}
|
||||
@ -59,6 +64,7 @@ type SectorSealed struct {
|
||||
commD []byte
|
||||
ticket SealTicket
|
||||
}
|
||||
|
||||
func (evt SectorSealed) apply(state *SectorInfo) {
|
||||
state.CommD = evt.commD
|
||||
state.CommR = evt.commR
|
||||
@ -66,14 +72,17 @@ func (evt SectorSealed) apply(state *SectorInfo) {
|
||||
}
|
||||
|
||||
type SectorSealFailed struct{ error }
|
||||
|
||||
func (evt SectorSealFailed) apply(*SectorInfo) {}
|
||||
|
||||
type SectorPreCommitFailed struct{ error }
|
||||
|
||||
func (evt SectorPreCommitFailed) apply(*SectorInfo) {}
|
||||
|
||||
type SectorPreCommitted struct {
|
||||
message cid.Cid
|
||||
}
|
||||
|
||||
func (evt SectorPreCommitted) apply(state *SectorInfo) {
|
||||
state.PreCommitMessage = &evt.message
|
||||
}
|
||||
@ -81,6 +90,7 @@ func (evt SectorPreCommitted) apply(state *SectorInfo) {
|
||||
type SectorSeedReady struct {
|
||||
seed SealSeed
|
||||
}
|
||||
|
||||
func (evt SectorSeedReady) apply(state *SectorInfo) {
|
||||
state.Seed = evt.seed
|
||||
}
|
||||
@ -91,18 +101,22 @@ type SectorCommitted struct {
|
||||
message cid.Cid
|
||||
proof []byte
|
||||
}
|
||||
|
||||
func (evt SectorCommitted) apply(state *SectorInfo) {
|
||||
state.Proof = evt.proof
|
||||
state.CommitMessage = &evt.message
|
||||
}
|
||||
|
||||
type SectorProving struct{}
|
||||
|
||||
func (evt SectorProving) apply(*SectorInfo) {}
|
||||
|
||||
type SectorFaulty struct{}
|
||||
|
||||
func (evt SectorFaulty) apply(state *SectorInfo) {}
|
||||
|
||||
type SectorFaultReported struct{ reportMsg cid.Cid }
|
||||
|
||||
func (evt SectorFaultReported) apply(state *SectorInfo) {
|
||||
state.FaultReportMsg = &evt.reportMsg
|
||||
}
|
||||
|
@ -72,12 +72,12 @@ func TestSeedRevert(t *testing.T) {
|
||||
m.planSingle(SectorSeedReady{})
|
||||
require.Equal(m.t, m.state.State, api.Committing)
|
||||
|
||||
_, err := m.s.plan([]statemachine.Event{{SectorSeedReady{seed:SealSeed{BlockHeight: 5,}}}, {SectorCommitted{}}}, m.state)
|
||||
_, err := m.s.plan([]statemachine.Event{{SectorSeedReady{seed: SealSeed{BlockHeight: 5}}}, {SectorCommitted{}}}, m.state)
|
||||
require.NoError(t, err)
|
||||
require.Equal(m.t, m.state.State, api.Committing)
|
||||
|
||||
// not changing the seed this time
|
||||
_, err = m.s.plan([]statemachine.Event{{SectorSeedReady{seed:SealSeed{BlockHeight: 5,}}}, {SectorCommitted{}}}, m.state)
|
||||
_, err = m.s.plan([]statemachine.Event{{SectorSeedReady{seed: SealSeed{BlockHeight: 5}}}, {SectorCommitted{}}}, m.state)
|
||||
require.Equal(m.t, m.state.State, api.CommitWait)
|
||||
|
||||
m.planSingle(SectorProving{})
|
||||
|
@ -66,13 +66,13 @@ type Sealing struct {
|
||||
|
||||
func New(api sealingApi, events *events.Events, maddr address.Address, worker address.Address, ds datastore.Batching, sb sectorbuilder.Interface, tktFn TicketFn) *Sealing {
|
||||
s := &Sealing{
|
||||
api: api,
|
||||
api: api,
|
||||
events: events,
|
||||
|
||||
maddr: maddr,
|
||||
worker: worker,
|
||||
sb: sb,
|
||||
tktFn: tktFn,
|
||||
maddr: maddr,
|
||||
worker: worker,
|
||||
sb: sb,
|
||||
tktFn: tktFn,
|
||||
}
|
||||
|
||||
s.sectors = statemachine.New(namespace.Wrap(ds, datastore.NewKey(SectorStorePrefix)), s, SectorInfo{})
|
||||
@ -133,4 +133,3 @@ func (m *Sealing) newSector(ctx context.Context, sid uint64, dealID uint64, ppi
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user