From 76ac91db52e1b7b715536c87d63b145ce6be1286 Mon Sep 17 00:00:00 2001 From: Mathias Buus Date: Tue, 18 May 2021 15:31:55 +0200 Subject: [PATCH] allow passing in a custom socket to query as well. remove dead code --- lib/query.js | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lib/query.js b/lib/query.js index 662485a..39e4dbe 100644 --- a/lib/query.js +++ b/lib/query.js @@ -26,6 +26,7 @@ module.exports = class Query extends Readable { this._fromTable = false this._commit = opts.commit === true ? autoCommit : (opts.commit || null) this._commiting = false + this._ropts = { socket: (opts && opts.socket) || this.dht.rpc.socket, expectOk: false } const nodes = opts.nodes || opts.closest @@ -60,18 +61,6 @@ module.exports = class Query extends Readable { }) } - async commit (command = this.command, value = this.value, opts) { - if (typeof command === 'object' && command) return this.commit(undefined, undefined, command) - return this.dht.requestAll(this.target, command, value, this.closest, opts) - } - - async toArray () { - const all = [] - this.on('data', data => all.push(data)) - await this.finished() - return all - } - _addFromTable () { if (this._pending.length >= this.k) return this._fromTable = true @@ -238,7 +227,7 @@ module.exports = class Query extends Readable { _visit (node) { this.inflight++ - this.dht.request(this.target, this.command, this.value, node, { expectOk: false }) + this.dht.request(this.target, this.command, this.value, node, this._ropts) .then(this._onresolve, this._onreject) } }