hyperswarm-stats 1.3.0 → 1.3.1

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 (2) hide show
  1. package/index.js +5 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -13,7 +13,7 @@ class HyperswarmStats {
13
13
  this._fastRecoveriesOfClosedSwarmStreams = 0
14
14
  this._rtoCountOfClosedSwarmStreams = 0
15
15
 
16
- swarm.on('connection', conn => {
16
+ const onconnection = conn => {
17
17
  conn.on('close', () => {
18
18
  this._bytesTransmittedOverClosedSwarmStreams += conn.rawStream?.bytesTransmitted || 0
19
19
  this._packetsTransmittedOverClosedSwarmStreams += conn.rawStream?.packetsTransmitted || 0
@@ -23,7 +23,10 @@ class HyperswarmStats {
23
23
  this._fastRecoveriesOfClosedSwarmStreams += conn.rawStream?.fastRecoveries
24
24
  this._rtoCountOfClosedSwarmStreams += conn.rawStream?.rtoCount
25
25
  })
26
- })
26
+ }
27
+
28
+ for (const conn of swarm.connections) onconnection(conn)
29
+ swarm.on('connection', onconnection)
27
30
  }
28
31
 
29
32
  get connects () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperswarm-stats",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "Hyperswarm stats with prometheus support",
5
5
  "main": "index.js",
6
6
  "scripts": {