rename {storageMinerApi=>fullNodeFilteredAPI}; add docs.

This commit is contained in:
Raúl Kripalani 2021-05-13 14:36:16 +01:00
parent 1d6941b0eb
commit c7d50fe195
5 changed files with 14 additions and 11 deletions

View File

@ -31,10 +31,10 @@ import (
var _ sealing.SealingAPI = new(SealingAPIAdapter) var _ sealing.SealingAPI = new(SealingAPIAdapter)
type SealingAPIAdapter struct { type SealingAPIAdapter struct {
delegate storageMinerApi delegate fullNodeFilteredAPI
} }
func NewSealingAPIAdapter(api storageMinerApi) SealingAPIAdapter { func NewSealingAPIAdapter(api fullNodeFilteredAPI) SealingAPIAdapter {
return SealingAPIAdapter{delegate: api} return SealingAPIAdapter{delegate: api}
} }

View File

@ -42,7 +42,7 @@ import (
var log = logging.Logger("storageminer") var log = logging.Logger("storageminer")
type Miner struct { type Miner struct {
api storageMinerApi api fullNodeFilteredAPI
feeCfg config.MinerFeeConfig feeCfg config.MinerFeeConfig
h host.Host h host.Host
sealer sectorstorage.SectorManager sealer sectorstorage.SectorManager
@ -70,7 +70,9 @@ type SealingStateEvt struct {
Error string Error string
} }
type storageMinerApi interface { // fullNodeFilteredAPI is the subset of the full node API the Miner needs from
// a Lotus full node.
type fullNodeFilteredAPI interface {
// Call a read only method on actors (no interaction with the chain required) // Call a read only method on actors (no interaction with the chain required)
StateCall(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) StateCall(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error)
StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error) StateMinerSectors(context.Context, address.Address, *bitfield.BitField, types.TipSetKey) ([]*miner.SectorOnChainInfo, error)
@ -116,7 +118,7 @@ type storageMinerApi interface {
WalletHas(context.Context, address.Address) (bool, error) WalletHas(context.Context, address.Address) (bool, error)
} }
func NewMiner(api storageMinerApi, maddr address.Address, h host.Host, ds datastore.Batching, sealer sectorstorage.SectorManager, sc sealing.SectorIDCounter, verif ffiwrapper.Verifier, gsd dtypes.GetSealingConfigFunc, feeCfg config.MinerFeeConfig, journal journal.Journal, as *AddressSelector) (*Miner, error) { func NewMiner(api fullNodeFilteredAPI, maddr address.Address, h host.Host, ds datastore.Batching, sealer sectorstorage.SectorManager, sc sealing.SectorIDCounter, verif ffiwrapper.Verifier, gsd dtypes.GetSealingConfigFunc, feeCfg config.MinerFeeConfig, journal journal.Journal, as *AddressSelector) (*Miner, error) {
m := &Miner{ m := &Miner{
api: api, api: api,
feeCfg: feeCfg, feeCfg: feeCfg,

View File

@ -25,6 +25,7 @@ type changeHandlerAPI interface {
StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error) StateMinerProvingDeadline(context.Context, address.Address, types.TipSetKey) (*dline.Info, error)
startGeneratePoST(ctx context.Context, ts *types.TipSet, deadline *dline.Info, onComplete CompleteGeneratePoSTCb) context.CancelFunc startGeneratePoST(ctx context.Context, ts *types.TipSet, deadline *dline.Info, onComplete CompleteGeneratePoSTCb) context.CancelFunc
startSubmitPoST(ctx context.Context, ts *types.TipSet, deadline *dline.Info, posts []miner.SubmitWindowedPoStParams, onComplete CompleteSubmitPoSTCb) context.CancelFunc startSubmitPoST(ctx context.Context, ts *types.TipSet, deadline *dline.Info, posts []miner.SubmitWindowedPoStParams, onComplete CompleteSubmitPoSTCb) context.CancelFunc
onAbort(ts *types.TipSet, deadline *dline.Info) onAbort(ts *types.TipSet, deadline *dline.Info)
failPost(err error, ts *types.TipSet, deadline *dline.Info) failPost(err error, ts *types.TipSet, deadline *dline.Info)
} }

View File

@ -35,7 +35,7 @@ import (
type mockStorageMinerAPI struct { type mockStorageMinerAPI struct {
partitions []api.Partition partitions []api.Partition
pushedMessages chan *types.Message pushedMessages chan *types.Message
storageMinerApi fullNodeFilteredAPI
} }
func newMockStorageMinerAPI() *mockStorageMinerAPI { func newMockStorageMinerAPI() *mockStorageMinerAPI {
@ -389,4 +389,4 @@ func (m *mockStorageMinerAPI) WalletHas(ctx context.Context, address address.Add
return true, nil return true, nil
} }
var _ storageMinerApi = &mockStorageMinerAPI{} var _ fullNodeFilteredAPI = &mockStorageMinerAPI{}

View File

@ -24,7 +24,7 @@ import (
) )
type WindowPoStScheduler struct { type WindowPoStScheduler struct {
api storageMinerApi api fullNodeFilteredAPI
feeCfg config.MinerFeeConfig feeCfg config.MinerFeeConfig
addrSel *AddressSelector addrSel *AddressSelector
prover storage.Prover prover storage.Prover
@ -43,7 +43,7 @@ type WindowPoStScheduler struct {
// failLk sync.Mutex // failLk sync.Mutex
} }
func NewWindowedPoStScheduler(api storageMinerApi, fc config.MinerFeeConfig, as *AddressSelector, sb storage.Prover, verif ffiwrapper.Verifier, ft sectorstorage.FaultTracker, j journal.Journal, actor address.Address) (*WindowPoStScheduler, error) { func NewWindowedPoStScheduler(api fullNodeFilteredAPI, fc config.MinerFeeConfig, as *AddressSelector, sb storage.Prover, verif ffiwrapper.Verifier, ft sectorstorage.FaultTracker, j journal.Journal, actor address.Address) (*WindowPoStScheduler, error) {
mi, err := api.StateMinerInfo(context.TODO(), actor, types.EmptyTSK) mi, err := api.StateMinerInfo(context.TODO(), actor, types.EmptyTSK)
if err != nil { if err != nil {
return nil, xerrors.Errorf("getting sector size: %w", err) return nil, xerrors.Errorf("getting sector size: %w", err)
@ -71,13 +71,13 @@ func NewWindowedPoStScheduler(api storageMinerApi, fc config.MinerFeeConfig, as
} }
type changeHandlerAPIImpl struct { type changeHandlerAPIImpl struct {
storageMinerApi fullNodeFilteredAPI
*WindowPoStScheduler *WindowPoStScheduler
} }
func (s *WindowPoStScheduler) Run(ctx context.Context) { func (s *WindowPoStScheduler) Run(ctx context.Context) {
// Initialize change handler // Initialize change handler
chImpl := &changeHandlerAPIImpl{storageMinerApi: s.api, WindowPoStScheduler: s} chImpl := &changeHandlerAPIImpl{fullNodeFilteredAPI: s.api, WindowPoStScheduler: s}
s.ch = newChangeHandler(chImpl, s.actor) s.ch = newChangeHandler(chImpl, s.actor)
defer s.ch.shutdown() defer s.ch.shutdown()
s.ch.start() s.ch.start()