Skip to content

Commit

Permalink
count the number of connection events (#173)
Browse files Browse the repository at this point in the history
* count the number of connection events

* PR feedback
  • Loading branch information
billiegoose authored Jun 5, 2024
1 parent 50424ac commit 9fc68b6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = class Hyperswarm extends EventEmitter {
this.peers = new Map()
this.explicitPeers = new Set()
this.listening = null
this.stats = { updates: 0 }

this._discovery = new Map()
this._timer = new RetryTimer(this._requeue.bind(this), {
Expand All @@ -74,6 +75,7 @@ module.exports = class Hyperswarm extends EventEmitter {
this._firewall = firewall

this.dht.on('network-change', this._handleNetworkChange.bind(this))
this.on('update', this._handleUpdate)
}

_maybeRelayConnection (force) {
Expand Down Expand Up @@ -331,6 +333,10 @@ module.exports = class Hyperswarm extends EventEmitter {
return peerInfo
}

_handleUpdate () {
this.stats.updates++
}

_maybeDeletePeer (peerInfo) {
if (!peerInfo.shouldGC()) return

Expand Down

0 comments on commit 9fc68b6

Please sign in to comment.