hypercore 10.31.2 → 10.31.4

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/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
  }
package/lib/core.js CHANGED
@@ -473,7 +473,7 @@ module.exports = class Core {
473
473
 
474
474
  const adding = batch.length - treeLength
475
475
 
476
- batch.upgraded = batch.length > this.tree.length
476
+ batch.upgraded = !pending && batch.length > this.tree.length
477
477
  batch.treeLength = this.tree.length
478
478
  batch.ancestors = this.tree.length
479
479
  if (batch.upgraded && !pending) batch.signature = signature || this.verifier.sign(batch, keyPair)
@@ -507,7 +507,15 @@ module.exports = class Core {
507
507
  }
508
508
 
509
509
  const status = (batch.upgraded ? 0b0001 : 0) | updateContig(this.header, entry.bitfield, this.bitfield)
510
- if (!pending) this.onupdate(status, entry.bitfield, null, null)
510
+ if (!pending) {
511
+ // we already commit this, and now we signed it, so tell others
512
+ if (entry.treeUpgrade && treeLength > batch.treeLength) {
513
+ entry.bitfield.start = batch.treeLength
514
+ entry.bitfield.length = treeLength - batch.treeLength
515
+ }
516
+
517
+ this.onupdate(status, entry.bitfield, null, null)
518
+ }
511
519
 
512
520
  if (this._shouldFlush()) await this._flushOplog()
513
521
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.31.2",
3
+ "version": "10.31.4",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {