Skip to content

Commit 3efe960

Browse files
Merge pull request ipfs#27 from JustinDrake/cleanup
DRY up NewDHT
2 parents 853debe + f292dce commit 3efe960

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

dht.go

+2-16
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,11 @@ type IpfsDHT struct {
6969

7070
// NewDHT creates a new DHT object with the given peer as the 'local' host
7171
func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT {
72-
dht := makeDHT(ctx, h, dstore)
73-
74-
// register for network notifs.
75-
dht.host.Network().Notify((*netNotifiee)(dht))
76-
77-
dht.proc = goprocessctx.WithContextAndTeardown(ctx, func() error {
78-
// remove ourselves from network notifs.
79-
dht.host.Network().StopNotify((*netNotifiee)(dht))
80-
return nil
81-
})
82-
83-
dht.proc.AddChild(dht.providers.Process())
72+
dht := NewDHTClient(ctx, h, dstore)
8473

8574
h.SetStreamHandler(ProtocolDHT, dht.handleNewStream)
8675
h.SetStreamHandler(ProtocolDHTOld, dht.handleNewStream)
87-
88-
dht.Validator["pk"] = record.PublicKeyValidator
89-
dht.Selector["pk"] = record.PublicKeySelector
90-
76+
9177
return dht
9278
}
9379

0 commit comments

Comments
 (0)