mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-29 02:11:18 +00:00
chore: _isStarted is false when stop starts
This commit is contained in:
parent
0ac8252b4c
commit
c22508c3e4
@ -248,6 +248,7 @@ class Libp2p extends EventEmitter {
|
|||||||
log('libp2p is stopping')
|
log('libp2p is stopping')
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
this._isStarted = false
|
||||||
for (const service of this._discovery.values()) {
|
for (const service of this._discovery.values()) {
|
||||||
service.removeListener('peer', this._onDiscoveryPeer)
|
service.removeListener('peer', this._onDiscoveryPeer)
|
||||||
}
|
}
|
||||||
@ -259,7 +260,6 @@ class Libp2p extends EventEmitter {
|
|||||||
await this.peerStore.stop()
|
await this.peerStore.stop()
|
||||||
await this.connectionManager.stop()
|
await this.connectionManager.stop()
|
||||||
|
|
||||||
ping.unmount(this)
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.pubsub && this.pubsub.stop(),
|
this.pubsub && this.pubsub.stop(),
|
||||||
this._dht && this._dht.stop(),
|
this._dht && this._dht.stop(),
|
||||||
@ -268,6 +268,8 @@ class Libp2p extends EventEmitter {
|
|||||||
|
|
||||||
await this.transportManager.close()
|
await this.transportManager.close()
|
||||||
|
|
||||||
|
ping.unmount(this)
|
||||||
|
|
||||||
this.dialer.destroy()
|
this.dialer.destroy()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -275,7 +277,6 @@ class Libp2p extends EventEmitter {
|
|||||||
this.emit('error', err)
|
this.emit('error', err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._isStarted = false
|
|
||||||
log('libp2p has stopped')
|
log('libp2p has stopped')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user