Skip to content

Commit 28f2f2a

Browse files
author
Vibhav Pant
committed
Provide the entire config object to makeDHT.
1 parent 766aeee commit 28f2f2a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dht.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func New(ctx context.Context, h host.Host, options ...opts.Option) (*IpfsDHT, er
9999
if err := cfg.Apply(append([]opts.Option{opts.Defaults}, options...)...); err != nil {
100100
return nil, err
101101
}
102-
dht := makeDHT(ctx, h, cfg.Datastore, cfg.Protocols, cfg.BucketSize, cfg.RoutingTable.LatencyTolerance)
102+
dht := makeDHT(ctx, h, &cfg)
103103
dht.autoRefresh = cfg.RoutingTable.AutoRefresh
104104
dht.rtRefreshPeriod = cfg.RoutingTable.RefreshPeriod
105105
dht.rtRefreshQueryTimeout = cfg.RoutingTable.RefreshQueryTimeout
@@ -152,9 +152,9 @@ func NewDHTClient(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT
152152
return dht
153153
}
154154

155-
func makeDHT(ctx context.Context, h host.Host, dstore ds.Batching, protocols []protocol.ID, bucketSize int, latency time.Duration) *IpfsDHT {
155+
func makeDHT(ctx context.Context, h host.Host, cfg *opts.Options) *IpfsDHT {
156156
self := kb.ConvertPeerID(h.ID())
157-
rt := kb.NewRoutingTable(bucketSize, self, latency, h.Peerstore())
157+
rt := kb.NewRoutingTable(cfg.BucketSize, self, cfg.RoutingTable.LatencyTolerance, h.Peerstore())
158158
cmgr := h.ConnManager()
159159

160160
rt.PeerAdded = func(p peer.ID) {
@@ -167,17 +167,17 @@ func makeDHT(ctx context.Context, h host.Host, dstore ds.Batching, protocols []p
167167
}
168168

169169
dht := &IpfsDHT{
170-
datastore: dstore,
170+
datastore: cfg.Datastore,
171171
self: h.ID(),
172172
peerstore: h.Peerstore(),
173173
host: h,
174174
strmap: make(map[peer.ID]*messageSender),
175175
ctx: ctx,
176-
providers: providers.NewProviderManager(ctx, h.ID(), dstore),
176+
providers: providers.NewProviderManager(ctx, h.ID(), cfg.Datastore),
177177
birth: time.Now(),
178178
routingTable: rt,
179-
protocols: protocols,
180-
bucketSize: bucketSize,
179+
protocols: cfg.Protocols,
180+
bucketSize: cfg.BucketSize,
181181
triggerRtRefresh: make(chan chan<- error),
182182
}
183183

0 commit comments

Comments
 (0)