Skip to content

Commit 1e801be

Browse files
authored
remove debug option as its unused now (#204)
1 parent 77c67a9 commit 1e801be

File tree

4 files changed

+4
-42
lines changed

4 files changed

+4
-42
lines changed

index.js

-8
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ class HyperDHT extends DHT {
4646
this._randomPunches = 0
4747
this._randomPunchLimit = 1 // set to one for extra safety for now
4848

49-
this._debugStream = (opts.debug && opts.debug.stream) || null
50-
this._debugHandshakeLatency = toRange((opts.debug && opts.debug.handshake && opts.debug.handshake.latency) || 0)
51-
5249
this.once('persistent', () => {
5350
this._persistent = new Persistent(this, persistent)
5451
})
@@ -535,11 +532,6 @@ function mapMutable (node) {
535532

536533
function noop () {}
537534

538-
function toRange (n) {
539-
if (!n) return null
540-
return typeof n === 'number' ? [n, n] : n
541-
}
542-
543535
function filterNode (node) {
544536
// always skip these testnet nodes that got mixed in by accident, until they get updated
545537
return !(node.port === 49738 && (node.host === '134.209.28.98' || node.host === '167.99.142.185')) &&

lib/connect.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const NoiseSecretStream = require('@hyperswarm/secret-stream')
22
const b4a = require('b4a')
33
const relay = require('blind-relay')
4-
const DebuggingStream = require('debugging-stream')
54
const { isPrivate, isBogon } = require('bogon')
65
const safetyCatch = require('safety-catch')
76
const unslab = require('unslab')
@@ -426,12 +425,7 @@ async function connectThroughNode (c, address, socket) {
426425
if (remoteChanging) remoteChanging.catch(safetyCatch)
427426
} else {
428427
c.rawStream.connect(socket, c.connect.payload.udx.id, port, host)
429-
430-
const rawStream = c.dht._debugStream !== null
431-
? new DebuggingStream(c.rawStream, c.dht._debugStream)
432-
: c.rawStream
433-
434-
c.encryptedSocket.start(rawStream, { handshake: hs })
428+
c.encryptedSocket.start(c.rawStream, { handshake: hs })
435429
}
436430

437431
if (c.reusableSocket && payload.udx.reusableSocket) {
@@ -725,11 +719,7 @@ function relayConnection (c, relayThrough, payload, hs) {
725719
.on('close', () => c.relaySocket.destroy())
726720
.connect(socket, remoteId, remotePort, remoteHost)
727721

728-
const rawStream = c.dht._debugStream !== null
729-
? new DebuggingStream(c.rawStream, c.dht._debugStream)
730-
: c.rawStream
731-
732-
c.encryptedSocket.start(rawStream, { handshake: hs })
722+
c.encryptedSocket.start(c.rawStream, { handshake: hs })
733723
}
734724

735725
function onabort (err) {

lib/server.js

+2-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const { FIREWALL, ERROR } = require('./constants')
99
const { unslabbedHash } = require('./crypto')
1010
const SecurePayload = require('./secure-payload')
1111
const Holepuncher = require('./holepuncher')
12-
const DebuggingStream = require('debugging-stream')
1312
const { isPrivate } = require('bogon')
1413
const { ALREADY_LISTENING, NODE_DESTROYED } = require('./errors')
1514

@@ -304,12 +303,7 @@ module.exports = class Server extends EventEmitter {
304303
if (remoteChanging) remoteChanging.catch(safetyCatch)
305304
} else {
306305
hs.rawStream.connect(socket, remotePayload.udx.id, port, host)
307-
308-
const rawStream = this.dht._debugStream !== null
309-
? new DebuggingStream(hs.rawStream, this.dht._debugStream)
310-
: hs.rawStream
311-
312-
hs.encryptedSocket = this.createSecretStream(false, rawStream, {
306+
hs.encryptedSocket = this.createSecretStream(false, hs.rawStream, {
313307
handshake: h,
314308
keepAlive: this.dht.connectionKeepAlive
315309
})
@@ -363,11 +357,6 @@ module.exports = class Server extends EventEmitter {
363357
return null
364358
}
365359

366-
if (this.dht._debugHandshakeLatency !== null) {
367-
const [start, end] = this.dht._debugHandshakeLatency
368-
await sleep(start + Math.round(Math.random() * (end - start)))
369-
}
370-
371360
const h = handshake.final()
372361

373362
if (error !== ERROR.NONE) {
@@ -640,11 +629,7 @@ module.exports = class Server extends EventEmitter {
640629
.on('close', () => hs.relaySocket.destroy())
641630
.connect(socket, remoteId, remotePort, remoteHost)
642631

643-
const rawStream = this.dht._debugStream !== null
644-
? new DebuggingStream(hs.rawStream, this.dht._debugStream)
645-
: hs.rawStream
646-
647-
hs.encryptedSocket = this.createSecretStream(false, rawStream, { handshake: h })
632+
hs.encryptedSocket = this.createSecretStream(false, hs.rawStream, { handshake: h })
648633

649634
this.onconnection(hs.encryptedSocket)
650635
})
@@ -685,10 +670,6 @@ function defaultCreateSecretStream (isInitiator, rawStream, opts) {
685670
return new NoiseSecretStream(isInitiator, rawStream, opts)
686671
}
687672

688-
function sleep (ms) {
689-
return new Promise((resolve) => setTimeout(resolve, ms))
690-
}
691-
692673
function onlyPrivateHosts (addr) {
693674
return isPrivate(addr.host)
694675
}

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"bogon": "^1.0.0",
2929
"compact-encoding": "^2.4.1",
3030
"compact-encoding-net": "^1.0.1",
31-
"debugging-stream": "^2.0.0",
3231
"dht-rpc": "^6.15.1",
3332
"hypercore-crypto": "^3.3.0",
3433
"hypercore-id-encoding": "^1.2.0",

0 commit comments

Comments
 (0)