Commit d3b46b8d authored by rht's avatar rht

Use WithContextAndTeardown whenever possible

License: MIT
Signed-off-by: default avatarrht <rhtbot@gmail.com>
parent 50d59a42
......@@ -73,13 +73,12 @@ func NewDHT(ctx context.Context, h host.Host, dstore ds.ThreadSafeDatastore) *Ip
// register for network notifs.
dht.host.Network().Notify((*netNotifiee)(dht))
proc := goprocessctx.WithContext(ctx)
proc.SetTeardown(func() error {
dht.proc = goprocessctx.WithContextAndTeardown(ctx, func() error {
// remove ourselves from network notifs.
dht.host.Network().StopNotify((*netNotifiee)(dht))
return nil
})
dht.proc = proc
dht.ctx = ctx
h.SetStreamHandler(ProtocolDHT, dht.handleNewStream)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment