hypercore 10.35.0 → 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 +1 -2
- package/lib/core.js +1 -4
- package/lib/replicator.js +3 -3
- package/package.json +1 -1
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:
|
|
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
|
|
145
|
+
const bitfield = await Bitfield.open(bitfieldFile)
|
|
146
146
|
const blocks = new BlockStore(dataFile, tree)
|
|
147
147
|
|
|
148
148
|
if (overwrite) {
|
|
@@ -150,9 +150,6 @@ module.exports = class Core {
|
|
|
150
150
|
await blocks.clear()
|
|
151
151
|
await bitfield.clear()
|
|
152
152
|
entries = []
|
|
153
|
-
} else if (bitfield.resumed && header.tree.length === 0) {
|
|
154
|
-
// If this was an old bitfield, reset it since it loads based on disk size atm (TODO: change that)
|
|
155
|
-
await bitfield.clear()
|
|
156
153
|
}
|
|
157
154
|
|
|
158
155
|
// compat from earlier version that do not store contig length
|
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 = [
|
|
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 () {
|