Browse Source

Add `opts.size` to `dht.ping()` (#49)

master
Kasper Isager Dalsgarð 2 years ago
committed by GitHub
parent
commit
c4dd5f895a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      README.md
  2. 6
      index.js

12
README.md

@ -240,9 +240,17 @@ Options include:
Normally you'd set the token when commiting to the dht in the query's commit hook.
#### `reply = await node.ping(to)`
#### `reply = await node.ping(to, [options])`
Sugar for `dht.request({ command: 'ping' }, to)`
Sugar for `dht.request({ command: 'ping' }, to, options)`
Additional options include:
```js
{
size: 0, // size of the value buffer, filled with zeroes
}
```
#### `stream = node.query({ target, command, value }, [options])`

6
index.js

@ -143,7 +143,11 @@ class DHT extends EventEmitter {
}
ping ({ host, port }, opts) {
const req = this.io.createRequest({ id: null, host, port }, null, true, PING, null, null)
let value = null
if (opts && opts.size && opts.size > 0) value = b4a.alloc(opts.size)
const req = this.io.createRequest({ id: null, host, port }, null, true, PING, null, value)
return this._requestToPromise(req, opts)
}

Loading…
Cancel
Save