Skip to content

Commit

Permalink
Merge pull request #829 from libp2p/masih/fullrt_prov_mngr_opts
Browse files Browse the repository at this point in the history
Make provider manager options configurable in `fullrt`
  • Loading branch information
guillaumemichel authored Mar 14, 2023
2 parents 0239a32 + 5f45339 commit a83e0b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fullrt/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions fullrt/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -86,3 +88,11 @@ func WithTimeoutPerOperation(t time.Duration) Option {
return nil
}
}

// WithProviderManagerOptions sets the options to use when instantiating providers.ProviderManager.
func WithProviderManagerOptions(pmOpts ...providers.Option) Option {
return func(opt *config) error {
opt.pmOpts = pmOpts
return nil
}
}

0 comments on commit a83e0b2

Please sign in to comment.