hypercore 10.28.3 → 10.28.5

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
@@ -300,18 +300,22 @@ module.exports = class Hypercore extends EventEmitter {
300
300
 
301
301
  if (isFirst) {
302
302
  await this._openCapabilities(key, storage, opts)
303
- // Only the root session should pass capabilities to other sessions.
304
- for (let i = 0; i < this.sessions.length; i++) {
305
- const s = this.sessions[i]
306
- if (s !== this) s._passCapabilities(this)
307
- }
308
303
 
309
- // copy state over
310
- if (this._clone) {
311
- const { from, signature } = this._clone
312
- await from.opening
313
- await this.core.copyFrom(from.core, signature)
314
- this._clone = null
304
+ // check we are the actual root and not a opts.from session
305
+ if (!opts.from) {
306
+ // Only the root session should pass capabilities to other sessions.
307
+ for (let i = 0; i < this.sessions.length; i++) {
308
+ const s = this.sessions[i]
309
+ if (s !== this) s._passCapabilities(this)
310
+ }
311
+
312
+ // copy state over
313
+ if (this._clone) {
314
+ const { from, signature } = this._clone
315
+ await from.opening
316
+ await this.core.copyFrom(from.core, signature)
317
+ this._clone = null
318
+ }
315
319
  }
316
320
  }
317
321
 
package/lib/core.js CHANGED
@@ -284,6 +284,7 @@ module.exports = class Core {
284
284
  }
285
285
 
286
286
  this.header.userData = src.header.userData.slice(0)
287
+ this.header.hints.contiguousLength = Math.min(src.header.hints.contiguousLength, this.header.tree.length)
287
288
 
288
289
  await this._flushOplog()
289
290
  } finally {
package/lib/replicator.js CHANGED
@@ -10,7 +10,7 @@ const caps = require('./caps')
10
10
 
11
11
  const DEFAULT_MAX_INFLIGHT = [32, 512]
12
12
  const SCALE_LATENCY = 50
13
- const DEFAULT_SEGMENT_SIZE = 128 * 1024 // 128 KiB
13
+ const DEFAULT_SEGMENT_SIZE = 256 * 1024 * 8 // 256 KiB in bits
14
14
 
15
15
  const PRIORITY = {
16
16
  NORMAL: 0,
@@ -403,7 +403,7 @@ class Peer {
403
403
 
404
404
  this.sendSync()
405
405
 
406
- const contig = this.core.header.contiguousLength
406
+ const contig = this.core.header.hints.contiguousLength
407
407
  if (contig > 0) {
408
408
  this.broadcastRange(0, contig, false)
409
409
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.28.3",
3
+ "version": "10.28.5",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {