hypercore 10.35.1 → 10.35.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -60,7 +60,6 @@ module.exports = class Hypercore extends EventEmitter {
60
60
  this.crypto = opts.crypto || hypercoreCrypto
61
61
  this.core = null
62
62
  this.replicator = null
63
- this.inflightRange = opts.inflightRange || null
64
63
  this.encryption = null
65
64
  this.extensions = new Map()
66
65
  this.cache = createCache(opts.cache)
@@ -405,7 +404,7 @@ module.exports = class Hypercore extends EventEmitter {
405
404
  eagerUpgrade: true,
406
405
  notDownloadingLinger: opts.notDownloadingLinger,
407
406
  allowFork: opts.allowFork !== false,
408
- inflightRange: this.inflightRange,
407
+ inflightRange: opts.inflightRange,
409
408
  onpeerupdate: this._onpeerupdate.bind(this),
410
409
  onupload: this._onupload.bind(this),
411
410
  oninvalid: this._oninvalid.bind(this)
package/lib/core.js CHANGED
@@ -142,7 +142,7 @@ module.exports = class Core {
142
142
  const prologue = header.manifest ? header.manifest.prologue : null
143
143
 
144
144
  const tree = await MerkleTree.open(treeFile, { crypto, prologue, ...header.tree })
145
- const bitfield = await Bitfield.open(bitfieldFile, tree)
145
+ const bitfield = await Bitfield.open(bitfieldFile)
146
146
  const blocks = new BlockStore(dataFile, tree)
147
147
 
148
148
  if (overwrite) {
package/lib/replicator.js CHANGED
@@ -33,7 +33,7 @@ const m = require('./messages')
33
33
  const caps = require('./caps')
34
34
  const { createTracer } = require('hypertrace')
35
35
 
36
- const DEFAULT_MAX_INFLIGHT = [32, 512]
36
+ const DEFAULT_MAX_INFLIGHT = [16, 512]
37
37
  const SCALE_LATENCY = 50
38
38
  const DEFAULT_SEGMENT_SIZE = 256 * 1024 * 8 // 256 KiB in bits
39
39
  const NOT_DOWNLOADING_SLACK = 20000 + (Math.random() * 20000) | 0
@@ -369,8 +369,8 @@ class Peer {
369
369
  const stream = this.stream.rawStream
370
370
  if (!stream.udx) return Math.min(this.inflightRange[1], this.inflightRange[0] * 3)
371
371
 
372
- const scale = stream.rtt <= SCALE_LATENCY ? 1 : stream.rtt / SCALE_LATENCY
373
- return Math.round(Math.min(this.inflightRange[1], this.inflightRange[0] * scale))
372
+ const scale = stream.rtt <= SCALE_LATENCY ? 1 : stream.rtt / SCALE_LATENCY * Math.min(1, 2 / this.replicator.peers.length)
373
+ return Math.max(this.inflightRange[0], Math.round(Math.min(this.inflightRange[1], this.inflightRange[0] * scale)))
374
374
  }
375
375
 
376
376
  signalUpgrade () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.35.1",
3
+ "version": "10.35.2",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {