hypercore 11.39.5 → 11.39.6

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/replicator.js CHANGED
@@ -3173,6 +3173,7 @@ module.exports = class Replicator {
3173
3173
 
3174
3174
  attachTo(protomux) {
3175
3175
  if (this.destroyed) return
3176
+ if (protomux.stream.destroying) return
3176
3177
 
3177
3178
  const makePeer = this._makePeer.bind(this, protomux)
3178
3179
 
@@ -153,8 +153,9 @@ class SessionState {
153
153
  }
154
154
 
155
155
  async _updateSnapshotStorage(storage) {
156
- if (!this.atomized || !this.atomized.flushing) return this.treeInfo()
157
- while (this.atomized.flushing) await this.atomized.flushed()
156
+ const atom = this.atomized
157
+ if (!atom || !atom.flushing) return this.treeInfo()
158
+ while (atom.flushing) await atom.flushed()
158
159
 
159
160
  let rx = storage.read()
160
161
  const headPromise = rx.getHead()
@@ -597,11 +598,12 @@ class SessionState {
597
598
  const [left, right] = flat.spans(b)
598
599
  const s = left / 2
599
600
  const e = right / 2 + 1
600
- const has = s >= start && e <= end ? false : this.core.bitfield.hasSet(s, e - s)
601
+ const has = start <= s && e <= end ? false : this.core.bitfield.hasSet(s, e - s)
601
602
  if (has) break
602
603
 
603
604
  tx.deleteTreeNode(a)
604
- tx.deleteTreeNode(b)
605
+ // delete the whole sibling subtree as it isnt needed per `has` check
606
+ tx.deleteTreeNodeRange(left, right + 1)
605
607
  }
606
608
 
607
609
  if (this.isDefault()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.39.5",
3
+ "version": "11.39.6",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {