Comparing version 6.11.6 to 6.11.7
@@ -51,2 +51,7 @@ const DHT = require('dht-rpc') | ||
}) | ||
this.on('network-update', () => { | ||
if (!this.online) return | ||
for (const server of this.listening) server.notifyOnline() | ||
}) | ||
} | ||
@@ -190,2 +195,4 @@ | ||
if (!data.from.id) return data | ||
unannounces.push( | ||
@@ -192,0 +199,0 @@ dht._requestUnannounce( |
@@ -21,2 +21,3 @@ const safetyCatch = require('safety-catch') | ||
this.record = c.encode(m.peer, { publicKey: keyPair.publicKey, relayAddresses: [] }) | ||
this.online = new Signal() | ||
@@ -51,2 +52,6 @@ this._refreshing = false | ||
// Suspend has its own sleep logic | ||
// so we don't want to hang on this one | ||
this.online.notify() | ||
if (this._activeQuery) this._activeQuery.destroy() | ||
@@ -85,2 +90,3 @@ | ||
this.stopped = true | ||
this.online.notify() // Break out of the _background loop if we're offline | ||
this._sleeper.resume() | ||
@@ -123,2 +129,8 @@ this._resumed.notify() | ||
if (!this.stopped) await this._runUpdate() | ||
while (!this.dht.online && !this.stopped && !this.suspended) { | ||
// Being offline can make _background repeat very quickly | ||
// So wait until we're back online | ||
await this.online.wait() | ||
} | ||
} catch (err) { | ||
@@ -125,0 +137,0 @@ safetyCatch(err) |
@@ -190,2 +190,6 @@ const { EventEmitter } = require('events') | ||
notifyOnline () { | ||
if (this._announcer) this._announcer.online.notify() | ||
} | ||
_localAddresses () { | ||
@@ -192,0 +196,0 @@ return this.dht.validateLocalAddresses(Holepuncher.localAddresses(this.dht.io.serverSocket)) |
{ | ||
"name": "hyperdht", | ||
"version": "6.11.6", | ||
"version": "6.11.7", | ||
"description": "The DHT powering Hyperswarm", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
139555
3885