hyperswarm
Advanced tools
Comparing version 4.5.1 to 4.6.0
29
index.js
@@ -43,2 +43,3 @@ const { EventEmitter } = require('events') | ||
this.destroyed = false | ||
this.suspended = false | ||
this.maxPeers = maxPeers | ||
@@ -83,2 +84,3 @@ this.maxClientConnections = maxClientConnections | ||
_requeue (batch) { | ||
if (this.suspended) return | ||
for (const peerInfo of batch) { | ||
@@ -121,2 +123,3 @@ peerInfo.waiting = false | ||
return !this.destroyed && | ||
!this.suspended && | ||
this.connecting < this.maxParallel && | ||
@@ -128,2 +131,3 @@ this._allConnections.size < this.maxPeers && | ||
_shouldRequeue (peerInfo) { | ||
if (this.suspended) return false | ||
if (peerInfo.explicit) return true | ||
@@ -215,2 +219,3 @@ for (const topic of peerInfo.topics) { | ||
_handleFirewall (remotePublicKey, payload) { | ||
if (this.suspended) return true | ||
if (b4a.equals(remotePublicKey, this.keyPair.publicKey)) return true | ||
@@ -452,2 +457,26 @@ | ||
suspend () { | ||
if (this.suspended) return | ||
this.suspended = true | ||
for (const discovery of this._discovery.values()) { | ||
discovery.suspend() | ||
} | ||
for (const connection of this._allConnections) { | ||
connection.destroy() | ||
} | ||
} | ||
resume () { | ||
if (!this.suspended) return | ||
this.suspended = false | ||
for (const discovery of this._discovery.values()) { | ||
discovery.resume() | ||
} | ||
this._attemptClientConnections() | ||
} | ||
topics () { | ||
@@ -454,0 +483,0 @@ return this._discovery.values() |
@@ -15,2 +15,3 @@ const safetyCatch = require('safety-catch') | ||
this.destroying = null | ||
this.suspended = false | ||
@@ -121,3 +122,3 @@ this._sessions = [] | ||
if (this.destroyed) return | ||
if (this.suspended) return | ||
@@ -200,2 +201,18 @@ if (server === this.isServer && client === this.isClient) { | ||
} | ||
suspend () { | ||
if (this.suspended) return | ||
this.suspended = true | ||
if (this._timer) { | ||
clearTimeout(this._timer) | ||
this._timer = null | ||
} | ||
} | ||
resume () { | ||
if (!this.suspended) return | ||
this.suspended = false | ||
this.refresh() | ||
} | ||
} | ||
@@ -202,0 +219,0 @@ |
{ | ||
"name": "hyperswarm", | ||
"version": "4.5.1", | ||
"version": "4.6.0", | ||
"description": "A distributed networking stack for connecting peers", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35735
799