hypercore 11.0.18 → 11.0.20

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.
@@ -40,7 +40,7 @@ module.exports = class SessionState {
40
40
 
41
41
  if (treeInfo.roots.length) this.setRoots(treeInfo.roots)
42
42
 
43
- this.snapshotCompatLength = this.isSnapshot() ? this.length : -1
43
+ this.snapshotCompatLength = this.isSnapshot() ? Math.min(this.length, this.core.state.length) : -1
44
44
 
45
45
  this.active = 0
46
46
 
@@ -91,7 +91,8 @@ module.exports = class SessionState {
91
91
  }
92
92
 
93
93
  signedLength () {
94
- return Math.min(this.flushedLength(), this.core.state.length)
94
+ const l = Math.min(this.flushedLength(), this.core.state.length)
95
+ return this.isSnapshot() && l > this.snapshotCompatLength ? this.snapshotCompatLength : l
95
96
  }
96
97
 
97
98
  unref () {
@@ -350,6 +351,12 @@ module.exports = class SessionState {
350
351
 
351
352
  const { dependency, tree, roots } = await this._truncate(tx, batch)
352
353
 
354
+ for (const sessionState of this.core.sessionStates) {
355
+ if (sessionState.isSnapshot() && sessionState.name === this.name && length < sessionState.snapshotCompatLength) {
356
+ sessionState.snapshotCompatLength = length
357
+ }
358
+ }
359
+
353
360
  const flushed = await this.flush()
354
361
 
355
362
  this.fork = tree.fork
@@ -524,6 +531,12 @@ module.exports = class SessionState {
524
531
  if (!flushed) this._updateBitfield(bitfield)
525
532
  else if (this.isDefault()) this.core.ontruncate(tree, bitfield)
526
533
 
534
+ for (const sessionState of this.core.sessionStates) {
535
+ if (sessionState.isSnapshot() && sessionState.name === this.name && to < sessionState.snapshotCompatLength) {
536
+ sessionState.snapshotCompatLength = to
537
+ }
538
+ }
539
+
527
540
  for (let i = this.sessions.length - 1; i >= 0; i--) {
528
541
  this.sessions[i].emit('truncate', to, tree.fork)
529
542
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.0.18",
3
+ "version": "11.0.20",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -46,7 +46,6 @@
46
46
  "bare-events": "^2.2.0",
47
47
  "big-sparse-array": "^1.0.3",
48
48
  "compact-encoding": "^2.11.0",
49
- "crc-universal": "^1.0.2",
50
49
  "fast-fifo": "^1.3.0",
51
50
  "flat-tree": "^1.9.0",
52
51
  "hypercore-crypto": "^3.2.1",
@@ -56,7 +55,6 @@
56
55
  "is-options": "^1.0.1",
57
56
  "protomux": "^3.5.0",
58
57
  "quickbit-universal": "^2.2.0",
59
- "random-access-file": "^4.0.0",
60
58
  "random-array-iterator": "^1.0.0",
61
59
  "safety-catch": "^1.0.1",
62
60
  "sodium-universal": "^4.0.0",
@@ -69,8 +67,6 @@
69
67
  "debugging-stream": "^3.1.0",
70
68
  "hyperswarm": "^4.3.6",
71
69
  "rache": "^1.0.0",
72
- "random-access-memory": "^6.1.0",
73
- "random-access-memory-overlay": "^3.0.0",
74
70
  "range-parser": "^1.2.1",
75
71
  "speedometer": "^1.1.0",
76
72
  "standard": "^17.0.0",