diff --git a/command/daemon.go b/command/daemon.go index aedc2a1c0..afa177f07 100644 --- a/command/daemon.go +++ b/command/daemon.go @@ -170,8 +170,11 @@ func daemonAction(cctx *cli.Context) error { // Create indexer core indexerCore := engine.New(valueStore, engine.WithCache(resultCache)) - indexCounts := counter.NewIndexCounts(dstore) - indexCounts.SetTotalAddend(cfg.Indexer.IndexCountTotalAddend) + var indexCounts *counter.IndexCounts + if cfg.Ingest.IndexCountsEnabled || cfg.Finder.IndexCountsEnabled { + indexCounts = counter.NewIndexCounts(dstore) + indexCounts.SetTotalAddend(cfg.Indexer.IndexCountTotalAddend) + } // Create registry reg, err := registry.New(cctx.Context, cfg.Discovery, dstore, @@ -192,14 +195,17 @@ func daemonAction(cctx *cli.Context) error { if err != nil { return fmt.Errorf("bad find address %s: %s", findAddr, err) } - findSvr, err = httpfind.New(findNetAddr.String(), indexerCore, reg, + opts := []httpfind.Option{ httpfind.WithReadTimeout(time.Duration(cfg.Finder.ApiReadTimeout)), httpfind.WithWriteTimeout(time.Duration(cfg.Finder.ApiWriteTimeout)), httpfind.WithMaxConnections(cfg.Finder.MaxConnections), httpfind.WithHomepage(cfg.Finder.Webpage), - httpfind.WithIndexCounts(indexCounts), httpfind.WithVersion(cctx.App.Version), - ) + } + if cfg.Finder.IndexCountsEnabled { + opts = append(opts, httpfind.WithIndexCounts(indexCounts)) + } + findSvr, err = httpfind.New(findNetAddr.String(), indexerCore, reg, opts...) if err != nil { return err } @@ -247,9 +253,12 @@ func daemonAction(cctx *cli.Context) error { cfg.Ingest.ResendDirectAnnounce = false } + var ingestOpts []ingest.Option + if cfg.Ingest.IndexCountsEnabled { + ingestOpts = append(ingestOpts, ingest.WithIndexCounts(indexCounts)) + } // Initialize ingester. - ingester, err = ingest.NewIngester(cfg.Ingest, p2pHost, indexerCore, reg, dstore, dsTmp, - ingest.WithIndexCounts(indexCounts)) + ingester, err = ingest.NewIngester(cfg.Ingest, p2pHost, indexerCore, reg, dstore, dsTmp, ingestOpts...) if err != nil { return err } diff --git a/config/finder.go b/config/finder.go index 75d5e0575..80e03c0ba 100644 --- a/config/finder.go +++ b/config/finder.go @@ -20,6 +20,9 @@ type Finder struct { // Webpage is a domain to display when the homepage of the finder is // accessed over HTTP. Webpage string + // IndexCountsEnabled sets whether showing provider index count is enabled on the find server at /providers. + // Disabled by default. See Ingest.IndexCountsEnabled. + IndexCountsEnabled bool } func NewFinder() Finder { diff --git a/config/ingest.go b/config/ingest.go index 762400cf4..21bcd4cc1 100644 --- a/config/ingest.go +++ b/config/ingest.go @@ -76,6 +76,9 @@ type Ingest struct { // or a chain of advertisement entries. The value is an integer string // ending in "s", "m", "h" for seconds. minutes, hours. SyncTimeout Duration + // IndexCountsEnabled sets whether ingest process should count the number of index records per provider. + // Disabled by default. See: Finder.IndexCountsEnabled. + IndexCountsEnabled bool } type Mirror struct {