From f292dcebafd066302d5246531c06f06398acf86c Mon Sep 17 00:00:00 2001 From: Justin Drake Date: Mon, 14 Nov 2016 10:00:07 +0000 Subject: [PATCH] DRY up NewDHT --- dht.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/dht.go b/dht.go index bf2b7c54954..61096f57160 100644 --- a/dht.go +++ b/dht.go @@ -71,25 +71,11 @@ type IpfsDHT struct { // NewDHT creates a new DHT object with the given peer as the 'local' host func NewDHT(ctx context.Context, h host.Host, dstore ds.Batching) *IpfsDHT { - dht := makeDHT(ctx, h, dstore) - - // register for network notifs. - dht.host.Network().Notify((*netNotifiee)(dht)) - - dht.proc = goprocessctx.WithContextAndTeardown(ctx, func() error { - // remove ourselves from network notifs. - dht.host.Network().StopNotify((*netNotifiee)(dht)) - return nil - }) - - dht.proc.AddChild(dht.providers.Process()) + dht := NewDHTClient(ctx, h, dstore) h.SetStreamHandler(ProtocolDHT, dht.handleNewStream) h.SetStreamHandler(ProtocolDHTOld, dht.handleNewStream) - - dht.Validator["pk"] = record.PublicKeyValidator - dht.Selector["pk"] = record.PublicKeySelector - + return dht }