blind-peer 2.7.5 → 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.
Files changed (3) hide show
  1. package/index.js +12 -0
  2. package/lib/db.js +1 -2
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -192,6 +192,10 @@ class BlindPeer extends ReadyResource {
192
192
  return this.db.digest
193
193
  }
194
194
 
195
+ get nrAnnouncedCores () {
196
+ return this.announcedCores.size
197
+ }
198
+
195
199
  addTrustedPubKey (key) {
196
200
  this.trustedPubKeys.add(IdEnc.normalize(key))
197
201
  }
@@ -508,6 +512,14 @@ class BlindPeer extends ReadyResource {
508
512
  this.set(self.db.stats.flushes)
509
513
  }
510
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
+ })
511
523
  }
512
524
  }
513
525
 
package/lib/db.js CHANGED
@@ -129,8 +129,6 @@ module.exports = class BlindPeerDB extends ReadyResource {
129
129
  }
130
130
 
131
131
  if (addedCores || addedReferrers || bytesAllocated || this.closing) {
132
- this.stats.flushes++ // we only count those flushes where we update the db
133
-
134
132
  this.digest.cores += addedCores
135
133
  this.digest.referrers += addedReferrers
136
134
  this.digest.bytesAllocated += bytesAllocated
@@ -139,6 +137,7 @@ module.exports = class BlindPeerDB extends ReadyResource {
139
137
  await tx.insert('@blind-peer/digest', this.digest)
140
138
  }
141
139
 
140
+ if (tx.updates.size > 0) this.stats.flushes++ // we only count those flushes where we update the db
142
141
  await tx.flush()
143
142
  }
144
143
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blind-peer",
3
- "version": "2.7.5",
3
+ "version": "2.7.6",
4
4
  "description": "Blind peers help keep hypercores available",
5
5
  "main": "index.js",
6
6
  "bin": {