dht-rpc 6.9.1 → 6.10.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/lib/query.js +5 -0
- package/package.json +1 -1
package/lib/query.js
CHANGED
|
@@ -33,6 +33,7 @@ module.exports = class Query extends Readable {
|
|
|
33
33
|
this._commiting = false
|
|
34
34
|
this._session = opts.session || dht.session()
|
|
35
35
|
this._autoDestroySession = !opts.session
|
|
36
|
+
this._onlyClosestNodes = false
|
|
36
37
|
|
|
37
38
|
this._onvisitbound = this._onvisit.bind(this)
|
|
38
39
|
this._onerrorbound = this._onerror.bind(this)
|
|
@@ -52,6 +53,8 @@ module.exports = class Query extends Readable {
|
|
|
52
53
|
this._addPending(replies[i].from, null)
|
|
53
54
|
}
|
|
54
55
|
}
|
|
56
|
+
|
|
57
|
+
if (opts.onlyClosestNodes) this._onlyClosestNodes = true
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
get closestNodes () {
|
|
@@ -113,6 +116,8 @@ module.exports = class Query extends Readable {
|
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
_addPending (node, ref) {
|
|
119
|
+
if (this._onlyClosestNodes) return false
|
|
120
|
+
|
|
116
121
|
const addr = node.host + ':' + node.port
|
|
117
122
|
const refs = this._seen.get(addr)
|
|
118
123
|
const isCloser = this._isCloser(node.id)
|