hyperswarm
Advanced tools
Comparing version 4.3.7 to 4.4.0
27
index.js
@@ -47,2 +47,3 @@ const { EventEmitter } = require('events') | ||
this.maxParallel = maxParallel | ||
this.connecting = 0 | ||
this.connections = new Set() | ||
@@ -65,3 +66,2 @@ this.peers = new Map() | ||
this._drainingQueue = false | ||
this._connecting = 0 | ||
this._clientConnections = 0 | ||
@@ -105,3 +105,3 @@ this._serverConnections = 0 | ||
_flushAllMaybe () { | ||
if (this._connecting > 0 || (this._allConnections.size < this.maxPeers && this._clientConnections < this.maxClientConnections)) { | ||
if (this.connecting > 0 || (this._allConnections.size < this.maxPeers && this._clientConnections < this.maxClientConnections)) { | ||
return false | ||
@@ -120,3 +120,3 @@ } | ||
return !this.destroyed && | ||
this._connecting < this.maxParallel && | ||
this.connecting < this.maxParallel && | ||
this._allConnections.size < this.maxPeers && | ||
@@ -154,3 +154,3 @@ this._clientConnections < this.maxClientConnections | ||
this._allConnections.add(conn) | ||
this._connecting++ | ||
this.connecting++ | ||
this._clientConnections++ | ||
@@ -169,2 +169,4 @@ let opened = false | ||
this._attemptClientConnections() | ||
this.emit('update') | ||
}) | ||
@@ -181,9 +183,14 @@ conn.on('error', noop) | ||
this._flushMaybe(peerInfo) | ||
this.emit('update') | ||
}) | ||
this.emit('update') | ||
} | ||
_connectDone () { | ||
this._connecting-- | ||
if (this._connecting < this.maxParallel) this._attemptClientConnections() | ||
if (this._connecting === 0) this._flushAllMaybe() | ||
this.connecting-- | ||
if (this.connecting < this.maxParallel) this._attemptClientConnections() | ||
if (this.connecting === 0) this._flushAllMaybe() | ||
} | ||
@@ -202,3 +209,3 @@ | ||
this._drainingQueue = false | ||
if (this._connecting === 0) this._flushAllMaybe() | ||
if (this.connecting === 0) this._flushAllMaybe() | ||
} | ||
@@ -273,5 +280,9 @@ | ||
this._attemptClientConnections() | ||
this.emit('update') | ||
}) | ||
peerInfo.client = false | ||
this.emit('connection', conn, peerInfo) | ||
this.emit('update') | ||
} | ||
@@ -278,0 +289,0 @@ |
{ | ||
"name": "hyperswarm", | ||
"version": "4.3.7", | ||
"version": "4.4.0", | ||
"description": "A distributed networking stack for connecting peers", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -51,2 +51,5 @@ # hyperswarm | ||
#### `swarm.connecting` | ||
Number that indicates connections in progress. | ||
#### `swarm.connections` | ||
@@ -70,2 +73,7 @@ A set of all active client/server connections. | ||
#### `swarm.on('update', () => {})` | ||
Emitted when internal values are changed, useful for user interfaces. | ||
For example: emitted when `swarm.connecting` or `swarm.connections` changes. | ||
#### `const discovery = swarm.join(topic, opts = {})` | ||
@@ -72,0 +80,0 @@ Start discovering and connecting to peers sharing a common topic. As new peers are connected to, they will be emitted from the swarm as `connection` events. |
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
34320
749
165