hyperswarm
Advanced tools
Comparing version 4.7.3 to 4.7.4
38
index.js
@@ -174,2 +174,21 @@ const { EventEmitter } = require('events') | ||
conn.on('open', () => { | ||
opened = true | ||
this._connectDone() | ||
this.connections.add(conn) | ||
conn.removeListener('error', noop) | ||
peerInfo._connected() | ||
peerInfo.client = true | ||
this.emit('connection', conn, peerInfo) | ||
this._flushMaybe(peerInfo) | ||
this.emit('update') | ||
}) | ||
conn.on('error', err => { | ||
if (this.relayThrough && shouldForceRelaying(err.code)) { | ||
peerInfo.forceRelaying = true | ||
// Reset the attempts in order to fast connect to relay | ||
peerInfo.attempts = 0 | ||
} | ||
}) | ||
conn.on('close', () => { | ||
@@ -191,22 +210,3 @@ if (!opened) this._connectDone() | ||
}) | ||
conn.on('error', err => { | ||
if (this.relayThrough && shouldForceRelaying(err.code)) { | ||
peerInfo.forceRelaying = true | ||
// Reset the attempts in order to fast connect to relay | ||
peerInfo.attempts = 0 | ||
} | ||
}) | ||
conn.on('open', () => { | ||
opened = true | ||
this._connectDone() | ||
this.connections.add(conn) | ||
conn.removeListener('error', noop) | ||
peerInfo._connected() | ||
peerInfo.client = true | ||
this.emit('connection', conn, peerInfo) | ||
this._flushMaybe(peerInfo) | ||
this.emit('update') | ||
}) | ||
this.emit('update') | ||
@@ -213,0 +213,0 @@ } |
const { EventEmitter } = require('events') | ||
const b4a = require('b4a') | ||
const MIN_CONNECTION_TIME = 15000 | ||
const VERY_LOW_PRIORITY = 0 | ||
@@ -19,2 +21,3 @@ const LOW_PRIORITY = 1 | ||
this.proven = false | ||
this.connectedTime = -1 | ||
this.banned = false | ||
@@ -63,6 +66,10 @@ this.tried = false | ||
this.proven = true | ||
this.attempts = 0 | ||
this.connectedTime = Date.now() | ||
} | ||
_disconnected () { | ||
if (this.connectedTime > -1) { | ||
if ((Date.now() - this.connectedTime) >= MIN_CONNECTION_TIME) this.attempts = 0 // fast retry | ||
this.connectedTime = -1 | ||
} | ||
this.attempts++ | ||
@@ -69,0 +76,0 @@ } |
{ | ||
"name": "hyperswarm", | ||
"version": "4.7.3", | ||
"version": "4.7.4", | ||
"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
36957
831