Socket
Socket
Sign inDemoInstall

hyperswarm

Package Overview
Dependencies
Maintainers
4
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperswarm - npm Package Compare versions

Comparing version 4.0.2 to 4.1.0

7

index.js

@@ -73,2 +73,3 @@ const { EventEmitter } = require('events')

_enqueue (peerInfo) {
if (peerInfo.queued) return
peerInfo.queued = true

@@ -83,3 +84,3 @@ peerInfo._flushTick = this._flushTick

for (const peerInfo of batch) {
if ((peerInfo._updatePriority() === false) || this._allConnections.has(peerInfo.publicKey)) continue
if ((peerInfo._updatePriority() === false) || this._allConnections.has(peerInfo.publicKey) || peerInfo.queued) continue
peerInfo.queued = true

@@ -124,3 +125,3 @@ peerInfo._flushTick = this._flushTick

_shouldRequeue (peerInfo) {
if (this.explicitPeers.has(peerInfo)) return true
if (peerInfo.explicit) return true
for (const topic of peerInfo.topics) {

@@ -353,2 +354,3 @@ if (this._discovery.has(b4a.toString(topic, 'hex')) && !this.destroyed) {

if (!this.explicitPeers.has(peerInfo)) {
peerInfo.explicit = true
this.explicitPeers.add(peerInfo)

@@ -366,2 +368,3 @@ }

const peerInfo = this.peers.get(keyString)
peerInfo.explicit = false
this.explicitPeers.delete(peerInfo)

@@ -368,0 +371,0 @@ }

@@ -21,2 +21,3 @@ const { EventEmitter } = require('events')

this.tried = false
this.explicit = false

@@ -79,2 +80,3 @@ // Set by the Swarm

_updatePriority () {
if (this.explicit && this.attempts > 3) this._deprioritize()
if (this.banned || this.queued || this.attempts > 3) return false

@@ -81,0 +83,0 @@ this.priority = this._getPriority()

@@ -5,7 +5,8 @@ const BulkTimer = require('./bulk-timer')

const BACKOFF_S = 1000 + Math.round(BACKOFF_JITTER * Math.random())
const BACKOFF_M = 5000 + Math.round(BACKOFF_JITTER * Math.random())
const BACKOFF_L = 15000 + Math.round(BACKOFF_JITTER * Math.random())
const BACKOFF_M = 5000 + Math.round(2 * BACKOFF_JITTER * Math.random())
const BACKOFF_L = 15000 + Math.round(4 * BACKOFF_JITTER * Math.random())
const BACKOFF_X = 1000 * 60 * 10 + Math.round(240 * BACKOFF_JITTER * Math.random())
module.exports = class RetryTimer {
constructor (push, { backoffs = [BACKOFF_S, BACKOFF_M, BACKOFF_L], jitter = BACKOFF_JITTER } = {}) {
constructor (push, { backoffs = [BACKOFF_S, BACKOFF_M, BACKOFF_L, BACKOFF_X], jitter = BACKOFF_JITTER } = {}) {
this.jitter = jitter

@@ -17,6 +18,12 @@ this.backoffs = backoffs

this._lTimer = new BulkTimer(backoffs[2] + Math.round(jitter * Math.random()), push)
this._xTimer = new BulkTimer(backoffs[3] + Math.round(jitter * Math.random()), push)
}
_selectRetryTimer (peerInfo) {
if (peerInfo.banned || !peerInfo.reconnecting || peerInfo.attempts > 3) return null
if (peerInfo.banned || !peerInfo.reconnecting) return null
if (peerInfo.attempts > 3) {
return peerInfo.explicit ? this._xTimer : null
}
if (peerInfo.attempts === 0) return this._sTimer

@@ -36,2 +43,4 @@ if (peerInfo.proven) {

}
return null
}

@@ -49,3 +58,4 @@

this._lTimer.destroy()
this._xTimer.destroy()
}
}
{
"name": "hyperswarm",
"version": "4.0.2",
"version": "4.1.0",
"description": "A distributed networking stack for connecting peers",

@@ -5,0 +5,0 @@ "dependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc