Browse Source

allow passing in a custom socket to query as well. remove dead code

session-estimator
Mathias Buus 4 years ago
parent
commit
76ac91db52
  1. 15
      lib/query.js

15
lib/query.js

@ -26,6 +26,7 @@ module.exports = class Query extends Readable {
this._fromTable = false this._fromTable = false
this._commit = opts.commit === true ? autoCommit : (opts.commit || null) this._commit = opts.commit === true ? autoCommit : (opts.commit || null)
this._commiting = false this._commiting = false
this._ropts = { socket: (opts && opts.socket) || this.dht.rpc.socket, expectOk: false }
const nodes = opts.nodes || opts.closest 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 () { _addFromTable () {
if (this._pending.length >= this.k) return if (this._pending.length >= this.k) return
this._fromTable = true this._fromTable = true
@ -238,7 +227,7 @@ module.exports = class Query extends Readable {
_visit (node) { _visit (node) {
this.inflight++ 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) .then(this._onresolve, this._onreject)
} }
} }

Loading…
Cancel
Save