Skip to content

Commit

Permalink
Make provider manager options configurable in fullrt
Browse files Browse the repository at this point in the history
Implement the ability to configure provider manager options in `fullrt`
DHT client implementation.
  • Loading branch information
masih committed Mar 14, 2023
1 parent 0239a32 commit 536eb80
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(pmo ...providers.Option) Option {
return func(opt *config) error {
opt.pmOpts = pmo
return nil
}
}

0 comments on commit 536eb80

Please sign in to comment.