Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: config to disable piece doctor #1849

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions node/config/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func DefaultBoost() *Boost {
EmbeddedServicePort: 8042,
ServiceApiInfo: "",
ServiceRPCTimeout: Duration(15 * time.Minute),
EnablePieceDoctor: true,
},

ContractDeals: ContractDealsConfig{
Expand Down
6 changes: 6 additions & 0 deletions node/config/doc_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions node/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
33 changes: 19 additions & 14 deletions node/modules/piecedirectory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down