add RuntimeSubsystems API method; use it in lotus-miner info

This commit is contained in:
Anton Evangelatov
2021-07-29 04:38:19 -04:00
committed by Jennifer Wang
parent 5073c7e6cf
commit 9b7a7713a7
10 changed files with 580 additions and 280 deletions
+2
View File
@@ -72,6 +72,7 @@ func ConfigStorageMiner(c interface{}) Option {
return Options(
ConfigCommon(&cfg.Common, enableLibp2pNode),
Override(new([]api.MinerSubsystem), modules.AddMinerSubsystems(cfg.Subsystems)),
Override(new(stores.LocalStorage), From(new(repo.LockedRepo))),
Override(new(*stores.Local), modules.LocalStorage),
Override(new(*stores.Remote), modules.RemoteStorage),
@@ -215,6 +216,7 @@ func StorageMiner(out *api.StorageMiner, subsystemsCfg config.MinerSubsystemConf
func(s *Settings) error {
resAPI := &impl.StorageMinerAPI{}
s.invokes[ExtractApiKey] = fx.Populate(resAPI)
*out = resAPI
return nil
+6
View File
@@ -48,6 +48,8 @@ import (
type StorageMinerAPI struct {
fx.In
Subsystems api.MinerSubsystems
api.Common
api.Net
@@ -703,4 +705,8 @@ func (sm *StorageMinerAPI) ComputeProof(ctx context.Context, ssi []builtin.Secto
return sm.Epp.ComputeProof(ctx, ssi, rand)
}
func (sm *StorageMinerAPI) RuntimeSubsystems(context.Context) (res api.MinerSubsystems, err error) {
return sm.Subsystems, nil
}
var _ api.StorageMiner = &StorageMinerAPI{}
+17
View File
@@ -1007,3 +1007,20 @@ func mutateCfg(r repo.LockedRepo, mutator func(*config.StorageMiner)) error {
return multierr.Combine(typeErr, setConfigErr)
}
func AddMinerSubsystems(cfg config.MinerSubsystemConfig) (res api.MinerSubsystems) {
if cfg.EnableMining {
res = append(res, api.MiningSubsystem)
}
if cfg.EnableSealing {
res = append(res, api.SealingSubsystem)
}
if cfg.EnableSectorStorage {
res = append(res, api.SectorStorageSubsystem)
}
if cfg.EnableMarkets {
res = append(res, api.MarketsSubsystem)
}
return
}