hyperswarm
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -75,3 +75,8 @@ 'use strict' | ||
const queue = info.requeue() | ||
if (queue === -1) return false | ||
if (queue === -1) { | ||
// Either we exhausted reconnect attempts, the peer was banned or | ||
// reconnect is disabled. In any case - we have to remove the peer. | ||
this._remove[info.banned ? 1 : 0].push(info) | ||
return false | ||
} | ||
this._requeue[queue].push(info) | ||
@@ -93,3 +98,3 @@ return true | ||
// 'topic' event instead of making dup connections, per topic | ||
const id = toID(peer) + (peer.topic ? '@' + peer.topic.toString('hex') : '') | ||
const id = toID(peer) | ||
@@ -137,5 +142,6 @@ let info = this._infos.get(id) | ||
function toID (peer) { | ||
return peer.host + ':' + peer.port | ||
return peer.host + ':' + peer.port + | ||
(peer.topic ? '@' + peer.topic.toString('hex') : '') | ||
} | ||
module.exports.PeerQueue = PeerQueue |
{ | ||
"name": "hyperswarm", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A distributed networking stack for connecting peers", | ||
@@ -5,0 +5,0 @@ "main": "swarm.js", |
@@ -20,3 +20,3 @@ 'use strict' | ||
const q = queue({ | ||
requeue: [ 100, 200, 300 ] | ||
requeue: [ 100, 200, 300 ], | ||
}) | ||
@@ -38,5 +38,35 @@ | ||
is(q.requeue(info), false) | ||
q.destroy() | ||
}) | ||
test('requeue forget unresponsive', async ({ is }) => { | ||
const q = queue({ | ||
requeue: [ 100, 200, 300 ], | ||
forget: { unresponsive: 100 }, | ||
}) | ||
q.add({ port: 8080, host: '127.0.0.1' }) | ||
const info = q.shift() | ||
is(q.requeue(info), true) | ||
await once(q, 'readable') | ||
is(q.shift(), info) | ||
is(q.requeue(info), true) | ||
await once(q, 'readable') | ||
is(q.shift(), info) | ||
is(q.requeue(info), true) | ||
await once(q, 'readable') | ||
is(q.shift(), info) | ||
is(q.requeue(info), false) | ||
// Check that the info gets purged from the queue | ||
is(q._infos.size, 1) | ||
await timeout(200) | ||
is(q._infos.size, 0) | ||
q.destroy() | ||
}) | ||
test('peers with same details are deduped', async ({ is, same }) => { | ||
@@ -43,0 +73,0 @@ const q = queue() |
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
78114
2469