dht-rpc 6.21.0 → 6.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/index.js +3 -1
- package/lib/io.js +10 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,7 +123,9 @@ Options include:
|
|
|
123
123
|
// Optionally pass a UDX instance on which sockets will be created.
|
|
124
124
|
udx,
|
|
125
125
|
// dht-rpc will automatically detect if you are firewalled. If you know that you are not set this to false
|
|
126
|
-
firewalled: true
|
|
126
|
+
firewalled: true,
|
|
127
|
+
// dht-rpc will hint when a node is down if a request times out. Setting to false disables sending hints
|
|
128
|
+
sendDownHints: true
|
|
127
129
|
}
|
|
128
130
|
```
|
|
129
131
|
|
package/index.js
CHANGED
|
@@ -42,7 +42,7 @@ class DHT extends EventEmitter {
|
|
|
42
42
|
ontimeout: this._ontimeout.bind(this)
|
|
43
43
|
})
|
|
44
44
|
|
|
45
|
-
this.concurrency = opts.concurrency ||
|
|
45
|
+
this.concurrency = opts.concurrency || DEFAULTS.concurrency
|
|
46
46
|
this.bootstrapped = false
|
|
47
47
|
this.ephemeral = true
|
|
48
48
|
this.firewalled = this.io.firewalled
|
|
@@ -77,6 +77,7 @@ class DHT extends EventEmitter {
|
|
|
77
77
|
this._nonePersistentSamples = []
|
|
78
78
|
this._bootstrapping = this._bootstrap()
|
|
79
79
|
this._bootstrapping.catch(noop)
|
|
80
|
+
this._sendDownHints = opts.sendDownHints !== false
|
|
80
81
|
|
|
81
82
|
this.table.on('row', this._onrow)
|
|
82
83
|
|
|
@@ -355,6 +356,7 @@ class DHT extends EventEmitter {
|
|
|
355
356
|
}
|
|
356
357
|
|
|
357
358
|
_request(to, force, internal, command, target, value, session, onresponse, onerror) {
|
|
359
|
+
if (!this._sendDownHints && command === DOWN_HINT) return null
|
|
358
360
|
const req = this.io.createRequest(to, null, internal, command, target, value, session)
|
|
359
361
|
if (req === null) return null
|
|
360
362
|
|
package/lib/io.js
CHANGED
|
@@ -38,7 +38,13 @@ module.exports = class IO {
|
|
|
38
38
|
this.suspended = false
|
|
39
39
|
|
|
40
40
|
this.stats = {
|
|
41
|
-
requests: {
|
|
41
|
+
requests: {
|
|
42
|
+
active: 0,
|
|
43
|
+
total: 0,
|
|
44
|
+
responses: 0,
|
|
45
|
+
timeouts: 0,
|
|
46
|
+
retries: 0
|
|
47
|
+
},
|
|
42
48
|
commands: [
|
|
43
49
|
{ tx: 0, rx: 0 }, // tx = transmitted, rx = received
|
|
44
50
|
{ tx: 0, rx: 0 },
|
|
@@ -122,6 +128,7 @@ module.exports = class IO {
|
|
|
122
128
|
}
|
|
123
129
|
|
|
124
130
|
this.stats.requests.active--
|
|
131
|
+
this.stats.requests.responses++
|
|
125
132
|
|
|
126
133
|
this.onresponse(res, external)
|
|
127
134
|
req.onresponse(res, req)
|
|
@@ -578,9 +585,11 @@ function oncycle(req) {
|
|
|
578
585
|
req._timeout = null
|
|
579
586
|
req.oncycle(req)
|
|
580
587
|
if (req.sent >= req.retries) {
|
|
588
|
+
req._io.stats.requests.timeouts++
|
|
581
589
|
req.destroy(REQUEST_TIMEOUT())
|
|
582
590
|
req._io.ontimeout(req)
|
|
583
591
|
} else {
|
|
592
|
+
req._io.stats.requests.retries++
|
|
584
593
|
req.send()
|
|
585
594
|
}
|
|
586
595
|
}
|