hypercore 11.0.21 → 11.0.23

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.
@@ -123,16 +123,11 @@ module.exports = class BitInterlude {
123
123
 
124
124
  const buf = b4a.allocUnsafe(bitfield.getPageByteLength())
125
125
 
126
- const view = new DataView(
127
- buf.buffer,
128
- buf.byteOffset,
129
- buf.byteLength
130
- )
131
-
132
126
  if (page) {
133
- for (let i = 0; i < page.bitfield.length; i++) {
134
- view.setUint32(i * 4, page.bitfield[i], true)
135
- }
127
+ const src = page.bitfield // Uint32Array
128
+ buf.set(b4a.from(src.buffer, src.byteOffset, src.byteLength), 0)
129
+ } else {
130
+ b4a.fill(buf, 0)
136
131
  }
137
132
 
138
133
  const last = (pageIndex + 1) * (buf.byteLength << 3)
@@ -634,7 +634,6 @@ module.exports = class SessionState {
634
634
 
635
635
  try {
636
636
  if (length < this.length) throw INVALID_OPERATION('Can not catchup back in time')
637
- if (length === this.length) return
638
637
 
639
638
  const origLength = this.length
640
639
 
@@ -688,14 +687,12 @@ module.exports = class SessionState {
688
687
  this.storage.updateDependencyLength(sharedLength, true)
689
688
  this.storage.updateDependencyLength(length, false)
690
689
 
691
- const bitfield = { start: sharedLength, length: tree.length - sharedLength, drop: false }
692
-
693
690
  this.fork = tree.fork
694
691
  this.roots = roots
695
692
  this.length = tree.length
696
693
 
697
694
  if (truncating) this.ontruncate(tree, sharedLength, origLength, flushed)
698
- if (sharedLength < length) this.onappend(tree, bitfield, flushed)
695
+ if (sharedLength < length) this.onappend(tree, null, flushed)
699
696
  } finally {
700
697
  this.mutex.unlock()
701
698
  }
@@ -850,6 +847,7 @@ module.exports = class SessionState {
850
847
  srcLocked = true
851
848
 
852
849
  if (!(await this.core._validateCommit(state, treeLength))) return null
850
+ if (this.length > length) return null
853
851
 
854
852
  if (this.length < length && !signature) {
855
853
  if (!keyPair) keyPair = this.core.header.keyPair
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.0.21",
3
+ "version": "11.0.23",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {