hypercore 11.0.13 → 11.0.15

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
@@ -342,7 +342,7 @@ class Hypercore extends EventEmitter {
342
342
  this._setupSession(parent)
343
343
  }
344
344
 
345
- if (opts.exclusive) {
345
+ if (opts.exclusive && opts.writable !== false) {
346
346
  this.exclusive = true
347
347
  await this.core.lockExclusive()
348
348
  }
@@ -528,9 +528,7 @@ class Hypercore extends EventEmitter {
528
528
  }
529
529
 
530
530
  get signedLength () {
531
- if (this.opened === false) return 0
532
- if (this.state === this.core.state) return this.core.state.length
533
- return this.state.flushedLength()
531
+ return this.opened === false ? 0 : this.state.signedLength()
534
532
  }
535
533
 
536
534
  /**
@@ -90,6 +90,10 @@ module.exports = class SessionState {
90
90
  return 0
91
91
  }
92
92
 
93
+ signedLength () {
94
+ return Math.min(this.flushedLength(), this.core.state.length)
95
+ }
96
+
93
97
  unref () {
94
98
  if (--this.active > 0) return
95
99
  this.close().catch(noop) // technically async, but only for the last db session
@@ -555,7 +559,8 @@ module.exports = class SessionState {
555
559
  return
556
560
  }
557
561
 
558
- if (b.start !== p.start + p.length) {
562
+ const start = p.truncated === -1 ? p.start : p.truncated
563
+ if (b.start !== start + p.length) {
559
564
  throw INVALID_OPERATION('Atomic operations must be contiguous')
560
565
  }
561
566
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.0.13",
3
+ "version": "11.0.15",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {