diff --git a/node/builder.go b/node/builder.go index 9ca36d96a..62a81959a 100644 --- a/node/builder.go +++ b/node/builder.go @@ -551,7 +551,7 @@ func ConfigBoost(cfg *config.Boost) Option { Override(new(*server.GraphsyncUnpaidRetrieval), modules.RetrievalGraphsync(cfg.LotusDealmaking.SimultaneousTransfersForStorage, cfg.LotusDealmaking.SimultaneousTransfersForStoragePerClient, cfg.LotusDealmaking.SimultaneousTransfersForRetrieval)), Override(new(dtypes.StagingGraphsync), From(new(*server.GraphsyncUnpaidRetrieval))), Override(new(dtypes.ProviderPieceStore), modules.NewProviderPieceStore), - Override(StartPieceDoctorKey, modules.NewPieceDoctor), + Override(StartPieceDoctorKey, modules.NewPieceDoctor(cfg)), // Lotus Markets (retrieval deps) Override(new(sealer.PieceProvider), sealer.NewPieceProvider), diff --git a/node/config/def.go b/node/config/def.go index 989315a98..9f2855689 100644 --- a/node/config/def.go +++ b/node/config/def.go @@ -95,6 +95,7 @@ func DefaultBoost() *Boost { EmbeddedServicePort: 8042, ServiceApiInfo: "", ServiceRPCTimeout: Duration(15 * time.Minute), + EnablePieceDoctor: true, }, ContractDeals: ContractDealsConfig{ diff --git a/node/config/doc_gen.go b/node/config/doc_gen.go index f5fc43cd2..96b0e5dbb 100644 --- a/node/config/doc_gen.go +++ b/node/config/doc_gen.go @@ -666,6 +666,12 @@ Set this value to "" if the local index directory data service is embedded.`, Comment: `The RPC timeout when making requests to the boostd-data service`, }, + { + Name: "EnablePieceDoctor", + Type: "bool", + + Comment: `PieceDoctor runs a continuous background process to check each piece in LID for retrievability`, + }, }, "LocalIndexDirectoryLeveldbConfig": []DocField{ { diff --git a/node/config/types.go b/node/config/types.go index 8585d1105..279de42c0 100644 --- a/node/config/types.go +++ b/node/config/types.go @@ -430,6 +430,8 @@ type LocalIndexDirectoryConfig struct { ServiceApiInfo string // The RPC timeout when making requests to the boostd-data service ServiceRPCTimeout Duration + // PieceDoctor runs a continuous background process to check each piece in LID for retrievability + EnablePieceDoctor bool } type LocalIndexDirectoryLeveldbConfig struct { diff --git a/node/modules/piecedirectory.go b/node/modules/piecedirectory.go index d99088e40..846e3b3a0 100644 --- a/node/modules/piecedirectory.go +++ b/node/modules/piecedirectory.go @@ -163,20 +163,25 @@ func NewPieceStore(pm *piecedirectory.PieceDirectory, maddr address.Address) pie return &boostPieceStoreWrapper{piecedirectory: pm, maddr: maddr} } -func NewPieceDoctor(lc fx.Lifecycle, maddr lotus_dtypes.MinerAddress, store *bdclient.Store, ssm *sectorstatemgr.SectorStateMgr, fullnodeApi api.FullNode) *piecedirectory.Doctor { - doc := piecedirectory.NewDoctor(address.Address(maddr), store, ssm, fullnodeApi) - docctx, cancel := context.WithCancel(context.Background()) - lc.Append(fx.Hook{ - OnStart: func(ctx context.Context) error { - go doc.Run(docctx) - return nil - }, - OnStop: func(ctx context.Context) error { - cancel() - return nil - }, - }) - return doc +func NewPieceDoctor(cfg *config.Boost) func(lc fx.Lifecycle, maddr lotus_dtypes.MinerAddress, store *bdclient.Store, ssm *sectorstatemgr.SectorStateMgr, fullnodeApi api.FullNode) *piecedirectory.Doctor { + return func(lc fx.Lifecycle, maddr lotus_dtypes.MinerAddress, store *bdclient.Store, ssm *sectorstatemgr.SectorStateMgr, fullnodeApi api.FullNode) *piecedirectory.Doctor { + if !cfg.LocalIndexDirectory.EnablePieceDoctor { + return &piecedirectory.Doctor{} + } + doc := piecedirectory.NewDoctor(address.Address(maddr), store, ssm, fullnodeApi) + docctx, cancel := context.WithCancel(context.Background()) + lc.Append(fx.Hook{ + OnStart: func(ctx context.Context) error { + go doc.Run(docctx) + return nil + }, + OnStop: func(ctx context.Context) error { + cancel() + return nil + }, + }) + return doc + } } type boostPieceStoreWrapper struct {