Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ class HyperDHT extends DHT {

// stats is inherited from dht-rpc so fwd the ones from there
this.stats = { punches: { consistent: 0, random: 0, open: 0 }, ...this.stats }
this.rawStreams = new RawStreamSet(this)

this._router = new Router(this, router)
this._socketPool = new SocketPool(this, opts.host || '0.0.0.0')
this._rawStreams = new RawStreamSet(this)
this._persistent = null
this._validatedLocalAddresses = new Map()

Expand Down Expand Up @@ -95,11 +95,11 @@ class HyperDHT extends DHT {
log('Suspending all hyperdht servers')
await Promise.allSettled(suspending)
log('Done, clearing all raw streams')
await this._rawStreams.clear()
await this.rawStreams.clear()
log('Done, suspending dht-rpc')
await super.suspend({ log })
log('Done, clearing raw streams again')
await this._rawStreams.clear()
await this.rawStreams.clear()
log('Done, hyperdht fully suspended')
this._connectable = true
}
Expand All @@ -112,7 +112,7 @@ class HyperDHT extends DHT {
}
this._router.destroy()
if (this._persistent) this._persistent.destroy()
await this._rawStreams.clear()
await this.rawStreams.clear()
await this._socketPool.destroy()
await super.destroy()
}
Expand Down Expand Up @@ -431,7 +431,7 @@ class HyperDHT extends DHT {
}

createRawStream (opts) {
return this._rawStreams.add(opts)
return this.rawStreams.add(opts)
}

async _requestAnnounce (keyPair, dht, target, token, from, relayAddresses, sign) {
Expand Down
8 changes: 8 additions & 0 deletions lib/raw-stream-set.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ module.exports = class RawStreamSet {
this._streams = new Map()
}

get size () {
return this._streams.size
}

[Symbol.iterator] () {
return this._streams.values()
}

add (opts) {
const self = this

Expand Down
Loading