hypercore 11.21.0 → 11.21.2

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/replicator.js +11 -7
  2. package/package.json +1 -1
package/lib/replicator.js CHANGED
@@ -187,7 +187,7 @@ class RangeRequest extends Attachable {
187
187
  this.ifAvailable = ifAvailable
188
188
  this.blocks = blocks
189
189
  this.ranges = ranges
190
- this.rangeIndex = ranges.push(this) - 1
190
+ ranges.push(this)
191
191
 
192
192
  if (this.end === -1) {
193
193
  this.replicator._alwaysLatestBlock++
@@ -199,13 +199,12 @@ class RangeRequest extends Attachable {
199
199
  }
200
200
 
201
201
  _unref() {
202
- if (this.rangeIndex >= this.ranges.length) return
203
- if (this.ranges[this.rangeIndex] !== this) return
202
+ const rangeIndex = this.ranges.indexOf(this)
203
+ if (rangeIndex === -1) return
204
204
 
205
205
  const h = this.ranges.pop()
206
206
  if (h !== this) {
207
- this.ranges[this.rangeIndex] = h
208
- h.rangeIndex = this.rangeIndex
207
+ this.ranges[rangeIndex] = h
209
208
  }
210
209
 
211
210
  if (this.end === -1) {
@@ -922,10 +921,15 @@ class Peer {
922
921
  }
923
922
  }
924
923
 
924
+ let req = null
925
925
  const batch = this.core.storage.read()
926
- const req = await this._getProof(batch, msg, true)
927
- if (req === null) return
926
+ try {
927
+ req = await this._getProof(batch, msg, true)
928
+ } catch {
929
+ return
930
+ }
928
931
 
932
+ if (req === null) return
929
933
  batch.tryFlush()
930
934
 
931
935
  await this._fulfillRequest(req, true)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.21.0",
3
+ "version": "11.21.2",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {