hypercore 10.31.1 → 10.31.3

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.
Files changed (2) hide show
  1. package/lib/batch.js +6 -1
  2. package/package.json +1 -1
package/lib/batch.js CHANGED
@@ -45,6 +45,10 @@ module.exports = class HypercoreBatch extends EventEmitter {
45
45
  return Math.min(this._sessionLength, this.session.core === null ? 0 : this.session.core.tree.length)
46
46
  }
47
47
 
48
+ get flushedLength () {
49
+ return this._sessionLength
50
+ }
51
+
48
52
  get indexedByteLength () {
49
53
  return this._sessionByteLength
50
54
  }
@@ -185,6 +189,7 @@ module.exports = class HypercoreBatch extends EventEmitter {
185
189
 
186
190
  async restoreBatch (length) {
187
191
  if (this.opened === false) await this.opening
192
+ if (length >= this._sessionLength) return this.createTreeBatch(length)
188
193
  return this.session.core.tree.restoreBatch(length)
189
194
  }
190
195
 
@@ -355,7 +360,7 @@ module.exports = class HypercoreBatch extends EventEmitter {
355
360
  if (info === null) return false
356
361
 
357
362
  const delta = info.byteLength - this._sessionByteLength
358
- const newBatch = info.length !== this.session.length ? await this.restoreBatch(info.length) : this.session.createTreeBatch()
363
+ const newBatch = info.length !== this.session.length ? await this.session.core.tree.restoreBatch(info.length) : this.session.createTreeBatch()
359
364
 
360
365
  this._sessionLength = info.length
361
366
  this._sessionByteLength = info.byteLength
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.31.1",
3
+ "version": "10.31.3",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {