dht-rpc 6.11.2 → 6.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/index.js +1 -0
- package/lib/query.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,14 +126,14 @@ Options include:
|
|
|
126
126
|
```
|
|
127
127
|
|
|
128
128
|
Nodes per default use something called adaptive mode to decide whether or not they want to join other nodes' routing table.
|
|
129
|
-
This includes things like node uptime, if the node is firewalled etc. Adaptive mode is conservative, so it might take ~20-30 mins for the node to turn persistent. If you are making a test case with your own bootstrap network you'd usually want to turn this off to make sure your test finishes in a timely
|
|
129
|
+
This includes things like node uptime, if the node is firewalled etc. Adaptive mode is conservative, so it might take ~20-30 mins for the node to turn persistent. If you are making a test case with your own bootstrap network you'd usually want to turn this off to make sure your test finishes in a timely manner. You can do this by passing `ephemeral: false` in the constructor.
|
|
130
130
|
For the vast majority of use-cases you should always use adaptive mode to ensure good DHT health, ie the defaults.
|
|
131
131
|
|
|
132
132
|
Your DHT routing id is `hash(publicIp + publicPort)` and will be autoconfigured internally.
|
|
133
133
|
|
|
134
134
|
#### `const node = DHT.bootstrapper(port, host, [options])`
|
|
135
135
|
|
|
136
|
-
Make a bootstrap node for your DHT. The port and host needs to be
|
|
136
|
+
Make a bootstrap node for your DHT. The port and host needs to be its globally accessible port and host.
|
|
137
137
|
Note: `port` and `host` parameters are used to create the node id. Use `options.host` if you want to bind to i.e. 127.0.0.1.
|
|
138
138
|
DHT nodes can use any other DHT node to bootstrap, but a bootstrap node can bootstrap itself, by itself.
|
|
139
139
|
|
|
@@ -148,7 +148,7 @@ Get your own routing ID. Only available when the node is not ephemeral.
|
|
|
148
148
|
|
|
149
149
|
#### `node.ephemeral`
|
|
150
150
|
|
|
151
|
-
A boolean indicating if you are currently
|
|
151
|
+
A boolean indicating if you are currently ephemeral or not
|
|
152
152
|
|
|
153
153
|
#### `node.on('bootstrap')`
|
|
154
154
|
|
|
@@ -256,7 +256,7 @@ Options include:
|
|
|
256
256
|
}
|
|
257
257
|
```
|
|
258
258
|
|
|
259
|
-
Normally you'd set the token when
|
|
259
|
+
Normally you'd set the token when committing to the dht in the query's commit hook.
|
|
260
260
|
|
|
261
261
|
#### `reply = await node.ping(to, [options])`
|
|
262
262
|
|
|
@@ -315,7 +315,7 @@ Other options include:
|
|
|
315
315
|
// from a previous query.
|
|
316
316
|
],
|
|
317
317
|
map (reply) {
|
|
318
|
-
// map the reply into what you want returned on the
|
|
318
|
+
// map the reply into what you want returned on the stream
|
|
319
319
|
return { onlyValue: reply.value }
|
|
320
320
|
}
|
|
321
321
|
}
|
package/index.js
CHANGED
package/lib/query.js
CHANGED
|
@@ -10,6 +10,9 @@ module.exports = class Query extends Readable {
|
|
|
10
10
|
constructor (dht, target, internal, command, value, opts = {}) {
|
|
11
11
|
super()
|
|
12
12
|
|
|
13
|
+
dht.stats.queries.total++
|
|
14
|
+
dht.stats.queries.active++
|
|
15
|
+
|
|
13
16
|
this.dht = dht
|
|
14
17
|
this.k = this.dht.table.k
|
|
15
18
|
this.target = target
|
|
@@ -338,6 +341,7 @@ module.exports = class Query extends Readable {
|
|
|
338
341
|
}
|
|
339
342
|
|
|
340
343
|
_destroy (cb) {
|
|
344
|
+
this.dht.stats.queries.active--
|
|
341
345
|
if (!this._online && this.dht.online) this.dht._offline()
|
|
342
346
|
if (this._autoDestroySession) this._session.destroy()
|
|
343
347
|
cb(null)
|