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) } }