Unverified Commit 890f2e86 authored by Aarsh Shah's avatar Aarsh Shah Committed by GitHub

Close peerstore and document Host Close (#1037)

* close peerstore and docs change

* update docs
parent 1c850e12
......@@ -52,7 +52,7 @@ func ChainOptions(opts ...Option) Option {
// - If no peerstore is provided, the host is initialized with an empty
// peerstore.
//
// Canceling the passed context will stop the returned libp2p node.
// To stop/shutdown the returned libp2p node, the user needs to cancel the passed context and call `Close` on the returned Host.
func New(ctx context.Context, opts ...Option) (host.Host, error) {
return NewWithoutDefaults(ctx, append(opts, FallbackDefaults)...)
}
......
......@@ -1007,6 +1007,10 @@ func (h *BasicHost) Close() error {
_ = h.emitters.evtLocalAddrsUpdated.Close()
h.Network().Close()
if h.Peerstore() != nil {
h.Peerstore().Close()
}
h.refCount.Wait()
})
......
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