blind-peer 2.7.4 → 2.7.6
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/bin.js +2 -7
- package/index.js +52 -1
- package/lib/db.js +5 -0
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -43,13 +43,8 @@ const cmd = command('blind-peer',
|
|
|
43
43
|
|
|
44
44
|
const blindPeer = new BlindPeer(storage, { trustedPubKeys, maxBytes, port })
|
|
45
45
|
|
|
46
|
-
blindPeer.on('
|
|
47
|
-
|
|
48
|
-
logger.info(`post-to-mailbox request received for mailbox: ${idEnc.normalize(req.mailbox)} with message ${idEnc.normalize(req.message)})`)
|
|
49
|
-
} catch {
|
|
50
|
-
logger.info('Invalid post-to-mailbox request received')
|
|
51
|
-
logger.info(req)
|
|
52
|
-
}
|
|
46
|
+
blindPeer.on('flush-error', e => {
|
|
47
|
+
logger.warn(`Error while flushing the db: ${e.stack}`)
|
|
53
48
|
})
|
|
54
49
|
|
|
55
50
|
blindPeer.on('add-core', record => {
|
package/index.js
CHANGED
|
@@ -174,7 +174,9 @@ class BlindPeer extends ReadyResource {
|
|
|
174
174
|
|
|
175
175
|
this.stats = {
|
|
176
176
|
bytesGcd: 0,
|
|
177
|
-
coresAdded: 0
|
|
177
|
+
coresAdded: 0,
|
|
178
|
+
activations: 0,
|
|
179
|
+
wakeups: 0
|
|
178
180
|
}
|
|
179
181
|
}
|
|
180
182
|
|
|
@@ -190,6 +192,10 @@ class BlindPeer extends ReadyResource {
|
|
|
190
192
|
return this.db.digest
|
|
191
193
|
}
|
|
192
194
|
|
|
195
|
+
get nrAnnouncedCores () {
|
|
196
|
+
return this.announcedCores.size
|
|
197
|
+
}
|
|
198
|
+
|
|
193
199
|
addTrustedPubKey (key) {
|
|
194
200
|
this.trustedPubKeys.add(IdEnc.normalize(key))
|
|
195
201
|
}
|
|
@@ -224,6 +230,8 @@ class BlindPeer extends ReadyResource {
|
|
|
224
230
|
}
|
|
225
231
|
|
|
226
232
|
async _onwakeup (discoveryKey, muxer) {
|
|
233
|
+
this.stats.wakeups++
|
|
234
|
+
|
|
227
235
|
const auth = await this.store.storage.getAuth(discoveryKey)
|
|
228
236
|
if (!auth) return
|
|
229
237
|
|
|
@@ -331,6 +339,7 @@ class BlindPeer extends ReadyResource {
|
|
|
331
339
|
if (this.enableGc && this.needsGc()) await this._gc()
|
|
332
340
|
if (this.db.updated()) await this.db.flush()
|
|
333
341
|
} catch (e) {
|
|
342
|
+
this.emit('flush-error', e)
|
|
334
343
|
safetyCatch(e)
|
|
335
344
|
} finally {
|
|
336
345
|
this.lock.unlock()
|
|
@@ -355,6 +364,8 @@ class BlindPeer extends ReadyResource {
|
|
|
355
364
|
}
|
|
356
365
|
|
|
357
366
|
async _activateCore (stream, record) {
|
|
367
|
+
this.stats.activations++
|
|
368
|
+
|
|
358
369
|
const core = this.store.get({ key: record.key })
|
|
359
370
|
await core.ready()
|
|
360
371
|
|
|
@@ -454,6 +465,14 @@ class BlindPeer extends ReadyResource {
|
|
|
454
465
|
}
|
|
455
466
|
})
|
|
456
467
|
|
|
468
|
+
new promClient.Gauge({ // eslint-disable-line no-new
|
|
469
|
+
name: 'blind_peer_cores',
|
|
470
|
+
help: 'The amount of cores (as reported in its digest)',
|
|
471
|
+
collect () {
|
|
472
|
+
this.set(self.digest.cores)
|
|
473
|
+
}
|
|
474
|
+
})
|
|
475
|
+
|
|
457
476
|
new promClient.Gauge({ // eslint-disable-line no-new
|
|
458
477
|
name: 'blind_peer_cores_added',
|
|
459
478
|
help: 'The total amount of add-core RPC requests that have been processed',
|
|
@@ -469,6 +488,38 @@ class BlindPeer extends ReadyResource {
|
|
|
469
488
|
this.set(self.stats.bytesGcd)
|
|
470
489
|
}
|
|
471
490
|
})
|
|
491
|
+
|
|
492
|
+
new promClient.Gauge({ // eslint-disable-line no-new
|
|
493
|
+
name: 'blind_peer_core_activations',
|
|
494
|
+
help: 'The total amount of hypercore activations since the process started',
|
|
495
|
+
collect () {
|
|
496
|
+
this.set(self.stats.activations)
|
|
497
|
+
}
|
|
498
|
+
})
|
|
499
|
+
|
|
500
|
+
new promClient.Gauge({ // eslint-disable-line no-new
|
|
501
|
+
name: 'blind_peer_wakeups',
|
|
502
|
+
help: 'The total amount of hypercore wakeups since the process started',
|
|
503
|
+
collect () {
|
|
504
|
+
this.set(self.stats.wakeups)
|
|
505
|
+
}
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
new promClient.Gauge({ // eslint-disable-line no-new
|
|
509
|
+
name: 'blind_peer_db_flushes',
|
|
510
|
+
help: 'The total amount of database flushes since the process started',
|
|
511
|
+
collect () {
|
|
512
|
+
this.set(self.db.stats.flushes)
|
|
513
|
+
}
|
|
514
|
+
})
|
|
515
|
+
|
|
516
|
+
new promClient.Gauge({ // eslint-disable-line no-new
|
|
517
|
+
name: 'blind_peer_announced_cores',
|
|
518
|
+
help: 'The amount of announced cores',
|
|
519
|
+
collect () {
|
|
520
|
+
this.set(self.nrAnnouncedCores)
|
|
521
|
+
}
|
|
522
|
+
})
|
|
472
523
|
}
|
|
473
524
|
}
|
|
474
525
|
|
package/lib/db.js
CHANGED
|
@@ -20,6 +20,10 @@ module.exports = class BlindPeerDB extends ReadyResource {
|
|
|
20
20
|
this.coresAdding = []
|
|
21
21
|
this.coresUpdated = new Map()
|
|
22
22
|
|
|
23
|
+
this.stats = {
|
|
24
|
+
flushes: 0
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
this.ready().catch(noop)
|
|
24
28
|
}
|
|
25
29
|
|
|
@@ -133,6 +137,7 @@ module.exports = class BlindPeerDB extends ReadyResource {
|
|
|
133
137
|
await tx.insert('@blind-peer/digest', this.digest)
|
|
134
138
|
}
|
|
135
139
|
|
|
140
|
+
if (tx.updates.size > 0) this.stats.flushes++ // we only count those flushes where we update the db
|
|
136
141
|
await tx.flush()
|
|
137
142
|
}
|
|
138
143
|
|