From 536eb80c44622f385955b89459f4e7e97e29b149 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Mon, 13 Mar 2023 13:01:34 +0000 Subject: [PATCH] Make provider manager options configurable in `fullrt` Implement the ability to configure provider manager options in `fullrt` DHT client implementation. --- fullrt/dht.go | 2 +- fullrt/options.go | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fullrt/dht.go b/fullrt/dht.go index 003fdd1d2..cecd3fbe4 100644 --- a/fullrt/dht.go +++ b/fullrt/dht.go @@ -150,7 +150,7 @@ func NewFullRT(h host.Host, protocolPrefix protocol.ID, options ...Option) (*Ful ctx, cancel := context.WithCancel(context.Background()) - pm, err := providers.NewProviderManager(ctx, h.ID(), h.Peerstore(), dhtcfg.Datastore) + pm, err := providers.NewProviderManager(ctx, h.ID(), h.Peerstore(), dhtcfg.Datastore, fullrtcfg.pmOpts...) if err != nil { cancel() return nil, err diff --git a/fullrt/options.go b/fullrt/options.go index a469548a5..203497610 100644 --- a/fullrt/options.go +++ b/fullrt/options.go @@ -6,6 +6,7 @@ import ( kaddht "github.com/libp2p/go-libp2p-kad-dht" "github.com/libp2p/go-libp2p-kad-dht/crawler" + "github.com/libp2p/go-libp2p-kad-dht/providers" ) type config struct { @@ -16,6 +17,7 @@ type config struct { bulkSendParallelism int timeoutPerOp time.Duration crawler crawler.Crawler + pmOpts []providers.Option } func (cfg *config) apply(opts ...Option) error { @@ -86,3 +88,11 @@ func WithTimeoutPerOperation(t time.Duration) Option { return nil } } + +// WithProviderManagerOptions sets the options to use when instantiating providers.ProviderManager. +func WithProviderManagerOptions(pmo ...providers.Option) Option { + return func(opt *config) error { + opt.pmOpts = pmo + return nil + } +}