Browse Source

rebootstrap if we become unreachable

v4
Mathias Buus 5 years ago
parent
commit
a9bc5632ac
  1. 4
      index.js

4
index.js

@ -58,6 +58,7 @@ class DHT extends EventEmitter {
_ontick () {
this._tick++
if ((this._tick & 7) === 0) this._pingSome()
if ((this._tick & 63) === 0 && this.nodes.length < 20) this.bootstrap()
}
address () {
@ -268,6 +269,9 @@ class DHT extends EventEmitter {
var cnt = this.inflightQueries > 2 ? 1 : 3
var oldest = this.nodes.oldest
// tiny dht, ping the bootstrap again
if (!oldest) return this.bootstrap()
while (cnt--) {
if (!oldest || this._tick === oldest.tick) continue
this._check(oldest)

Loading…
Cancel
Save