Browse Source
Close peerstore and document Host Close (#1037)
* close peerstore and docs change
* update docs
pull/1075/head
Aarsh Shah
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
5 additions and
1 deletions
-
libp2p.go
-
p2p/host/basic/basic_host.go
|
@ -52,7 +52,7 @@ func ChainOptions(opts ...Option) Option { |
|
|
// - If no peerstore is provided, the host is initialized with an empty
|
|
|
// - If no peerstore is provided, the host is initialized with an empty
|
|
|
// peerstore.
|
|
|
// 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) { |
|
|
func New(ctx context.Context, opts ...Option) (host.Host, error) { |
|
|
return NewWithoutDefaults(ctx, append(opts, FallbackDefaults)...) |
|
|
return NewWithoutDefaults(ctx, append(opts, FallbackDefaults)...) |
|
|
} |
|
|
} |
|
|
|
@ -1007,6 +1007,10 @@ func (h *BasicHost) Close() error { |
|
|
_ = h.emitters.evtLocalAddrsUpdated.Close() |
|
|
_ = h.emitters.evtLocalAddrsUpdated.Close() |
|
|
h.Network().Close() |
|
|
h.Network().Close() |
|
|
|
|
|
|
|
|
|
|
|
if h.Peerstore() != nil { |
|
|
|
|
|
h.Peerstore().Close() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
h.refCount.Wait() |
|
|
h.refCount.Wait() |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|