dht-rpc 6.20.1 → 6.20.2
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/index.js +4 -2
- package/lib/io.js +2 -1
- package/lib/query.js +8 -1
- package/package.json +6 -3
package/index.js
CHANGED
|
@@ -479,8 +479,9 @@ class DHT extends EventEmitter {
|
|
|
479
479
|
oldest === null ||
|
|
480
480
|
oldest.pinged > node.pinged ||
|
|
481
481
|
(oldest.pinged === node.pinged && oldest.added > node.added)
|
|
482
|
-
)
|
|
482
|
+
) {
|
|
483
483
|
oldest = node
|
|
484
|
+
}
|
|
484
485
|
}
|
|
485
486
|
|
|
486
487
|
if (oldest === null) return
|
|
@@ -828,8 +829,9 @@ class DHT extends EventEmitter {
|
|
|
828
829
|
|
|
829
830
|
// check that the local port of the server socket is the same as the remote port
|
|
830
831
|
// TODO: we might want a flag to opt out of this heuristic for specific remapped port servers
|
|
831
|
-
if (natSampler.port === 0 || natSampler.port !== this.io.serverSocket.address().port)
|
|
832
|
+
if (natSampler.port === 0 || natSampler.port !== this.io.serverSocket.address().port) {
|
|
832
833
|
return true
|
|
834
|
+
}
|
|
833
835
|
|
|
834
836
|
return false
|
|
835
837
|
|
package/lib/io.js
CHANGED
|
@@ -413,8 +413,9 @@ class Request {
|
|
|
413
413
|
if (this.destroyed) return
|
|
414
414
|
|
|
415
415
|
if (this.socket === null) return
|
|
416
|
-
if (this._buffer === null)
|
|
416
|
+
if (this._buffer === null) {
|
|
417
417
|
this._buffer = this._encodeRequest(this.token, this.value, this.to, this.socket)
|
|
418
|
+
}
|
|
418
419
|
|
|
419
420
|
if (!force && this._io.congestion.isFull()) {
|
|
420
421
|
this._io._pending.push(this)
|
package/lib/query.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { Readable } = require('streamx')
|
|
1
|
+
const { Readable, getStreamError } = require('streamx')
|
|
2
2
|
const b4a = require('b4a')
|
|
3
3
|
const peer = require('./peer')
|
|
4
4
|
const { DOWN_HINT } = require('./commands')
|
|
@@ -82,6 +82,13 @@ module.exports = class Query extends Readable {
|
|
|
82
82
|
|
|
83
83
|
finished() {
|
|
84
84
|
return new Promise((resolve, reject) => {
|
|
85
|
+
if (this.destroyed) {
|
|
86
|
+
const error = getStreamError(this)
|
|
87
|
+
if (error) reject(error)
|
|
88
|
+
else resolve()
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
|
|
85
92
|
const self = this
|
|
86
93
|
let error = null
|
|
87
94
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dht-rpc",
|
|
3
|
-
"version": "6.20.
|
|
3
|
+
"version": "6.20.2",
|
|
4
4
|
"description": "Make RPC calls over a Kademlia based DHT",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -28,14 +28,17 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"brittle": "^3.0.0",
|
|
31
|
+
"lunte": "^1.3.0",
|
|
31
32
|
"prettier": "^3.6.2",
|
|
32
33
|
"prettier-config-holepunch": "^2.0.0",
|
|
33
34
|
"test-suspend": "^1.0.0"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
37
|
"format": "prettier --write .",
|
|
37
|
-
"test": "
|
|
38
|
-
"test:bare": "bare test.js"
|
|
38
|
+
"test": "npm run test:node && npm run test:bare",
|
|
39
|
+
"test:bare": "brittle-bare --coverage test.js",
|
|
40
|
+
"lint": "prettier --check . && lunte",
|
|
41
|
+
"test:node": "brittle-node --coverage test.js"
|
|
39
42
|
},
|
|
40
43
|
"repository": {
|
|
41
44
|
"type": "git",
|