diff --git a/itests/kit/ensemble.go b/itests/kit/ensemble.go index daca6d2d4..2a4bc6706 100644 --- a/itests/kit/ensemble.go +++ b/itests/kit/ensemble.go @@ -787,7 +787,9 @@ func (n *Ensemble) Start() *Ensemble { n.t.Cleanup(func() { _ = stop(context.Background()) }) mCopy := m n.t.Cleanup(func() { - mCopy.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB.ITestDeleteAll() + if mCopy.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB != nil { + mCopy.BaseAPI.(*impl.StorageMinerAPI).HarmonyDB.ITestDeleteAll() + } }) m.BaseAPI = m.StorageMiner diff --git a/node/builder_miner.go b/node/builder_miner.go index 99d5a201f..08c71ba19 100644 --- a/node/builder_miner.go +++ b/node/builder_miner.go @@ -104,9 +104,6 @@ func ConfigStorageMiner(c interface{}) Option { If(cfg.Subsystems.EnableSectorStorage, Error(xerrors.Errorf("sealing can only be enabled on a mining node"))), ), - Override(new(*harmonydb.DB), func(cfg config.HarmonyDB, id harmonydb.ITestID) (*harmonydb.DB, error) { - return harmonydb.NewFromConfigWithITestID(cfg)(id) - }), If(cfg.Subsystems.EnableMining, If(!cfg.Subsystems.EnableSealing, Error(xerrors.Errorf("sealing can't be disabled on a mining node yet"))), If(!cfg.Subsystems.EnableSectorStorage, Error(xerrors.Errorf("sealing can't be disabled on a mining node yet"))), @@ -139,6 +136,11 @@ func ConfigStorageMiner(c interface{}) Option { If(cfg.Subsystems.EnableSectorIndexDB, Override(new(*paths.DBIndex), paths.NewDBIndex), Override(new(paths.SectorIndex), From(new(*paths.DBIndex))), + + // sector index db is the only thing on lotus-miner that will use harmonydb + Override(new(*harmonydb.DB), func(cfg config.HarmonyDB, id harmonydb.ITestID) (*harmonydb.DB, error) { + return harmonydb.NewFromConfigWithITestID(cfg)(id) + }), ), If(!cfg.Subsystems.EnableSectorIndexDB, Override(new(*paths.MemIndex), paths.NewMemIndex), diff --git a/node/impl/storminer.go b/node/impl/storminer.go index b675772cf..2ce42c327 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -124,7 +124,7 @@ type StorageMinerAPI struct { GetExpectedSealDurationFunc dtypes.GetExpectedSealDurationFunc `optional:"true"` SetExpectedSealDurationFunc dtypes.SetExpectedSealDurationFunc `optional:"true"` - HarmonyDB *harmonydb.DB + HarmonyDB *harmonydb.DB `optional:"true"` } var _ api.StorageMiner = &StorageMinerAPI{}