minor refactor, renames, docs in Miner#Run.

This commit is contained in:
Raúl Kripalani 2021-05-14 19:47:50 +01:00
parent 0187aa6d9c
commit 89dfb0ba19

View File

@ -174,17 +174,37 @@ func (m *Miner) Run(ctx context.Context) error {
MaxTerminateGasFee: abi.TokenAmount(m.feeCfg.MaxTerminateGasFee), MaxTerminateGasFee: abi.TokenAmount(m.feeCfg.MaxTerminateGasFee),
} }
evts := events.NewEvents(ctx, m.api) var (
adaptedAPI := NewSealingAPIAdapter(m.api) // consumer of chain head changes.
// TODO: Maybe we update this policy after actor upgrades? evts = events.NewEvents(ctx, m.api)
pcp := sealing.NewBasicPreCommitPolicy(adaptedAPI, policy.GetMaxSectorExpirationExtension()-(md.WPoStProvingPeriod*2), md.PeriodStart%md.WPoStProvingPeriod) evtsAdapter = NewEventsAdapter(evts)
as := func(ctx context.Context, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) { // Create a shim to glue the API required by the sealing component
return m.addrSel.AddressFor(ctx, m.api, mi, use, goodFunds, minFunds) // with the API that Lotus is capable of providing.
} // The shim translates between "tipset tokens" and tipset keys, and
// provides extra methods.
adaptedAPI = NewSealingAPIAdapter(m.api)
m.sealing = sealing.New(adaptedAPI, fc, NewEventsAdapter(evts), m.maddr, m.ds, m.sealer, m.sc, m.verif, &pcp, sealing.GetSealingConfigFunc(m.getSealConfig), m.handleSealingNotifications, as) // Instantiate a precommit policy.
defaultDuration = policy.GetMaxSectorExpirationExtension() - (md.WPoStProvingPeriod * 2)
provingBoundary = md.PeriodStart % md.WPoStProvingPeriod
// TODO: Maybe we update this policy after actor upgrades?
pcp = sealing.NewBasicPreCommitPolicy(adaptedAPI, defaultDuration, provingBoundary)
// address selector.
as = func(ctx context.Context, mi miner.MinerInfo, use api.AddrUse, goodFunds, minFunds abi.TokenAmount) (address.Address, abi.TokenAmount, error) {
return m.addrSel.AddressFor(ctx, m.api, mi, use, goodFunds, minFunds)
}
// sealing configuration.
cfg = sealing.GetSealingConfigFunc(m.getSealConfig)
)
// Instantiate the sealing FSM.
m.sealing = sealing.New(adaptedAPI, fc, evtsAdapter, m.maddr, m.ds, m.sealer, m.sc, m.verif, &pcp, cfg, m.handleSealingNotifications, as)
// Run the sealing FSM.
go m.sealing.Run(ctx) //nolint:errcheck // logged intside the function go m.sealing.Run(ctx) //nolint:errcheck // logged intside the function
return nil return nil