Kasper Isager Dalsgarð
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
15 additions and
3 deletions
-
README.md
-
index.js
|
|
@ -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])` |
|
|
|
|
|
|
|
|
|
@ -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) |
|
|
|
} |
|
|
|
|
|
|
|