hypercore 10.31.8 → 10.31.9

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.
@@ -149,6 +149,7 @@ module.exports = class RemoteBitfield {
149
149
  constructor () {
150
150
  this._pages = new BigSparseArray()
151
151
  this._segments = new BigSparseArray()
152
+ this._maxSegments = 0
152
153
  }
153
154
 
154
155
  getBitfield (index) {
@@ -177,6 +178,7 @@ module.exports = class RemoteBitfield {
177
178
  if (!p && val) {
178
179
  const k = Math.floor(i / PAGES_PER_SEGMENT)
179
180
  const s = this._segments.get(k) || this._segments.set(k, new RemoteBitfieldSegment(k))
181
+ if (this._maxSegments <= k) this._maxSegments = k + 1
180
182
 
181
183
  p = this._pages.set(i, new RemoteBitfieldPage(i, new Uint32Array(WORDS_PER_PAGE), s))
182
184
  }
@@ -194,6 +196,7 @@ module.exports = class RemoteBitfield {
194
196
  if (!p && val) {
195
197
  const k = Math.floor(i / PAGES_PER_SEGMENT)
196
198
  const s = this._segments.get(k) || this._segments.set(k, new RemoteBitfieldSegment(k))
199
+ if (this._maxSegments <= k) this._maxSegments = k + 1
197
200
 
198
201
  p = this._pages.set(i, new RemoteBitfieldPage(i, new Uint32Array(WORDS_PER_PAGE), s))
199
202
  }
@@ -213,7 +216,7 @@ module.exports = class RemoteBitfield {
213
216
  let j = position & (BITS_PER_SEGMENT - 1)
214
217
  let i = (position - j) / BITS_PER_SEGMENT
215
218
 
216
- while (i < this._segments.maxLength) {
219
+ while (i < this._maxSegments) {
217
220
  const s = this._segments.get(i)
218
221
 
219
222
  let index = -1
@@ -281,6 +284,7 @@ module.exports = class RemoteBitfield {
281
284
  if (!p) {
282
285
  const k = Math.floor(i / PAGES_PER_SEGMENT)
283
286
  const s = this._segments.get(k) || this._segments.set(k, new RemoteBitfieldSegment(k))
287
+ if (this._maxSegments <= k) this._maxSegments = k + 1
284
288
 
285
289
  p = this._pages.set(i, new RemoteBitfieldPage(i, new Uint32Array(WORDS_PER_PAGE), s))
286
290
  }
@@ -314,6 +318,7 @@ module.exports = class RemoteBitfield {
314
318
  if (!p) {
315
319
  const k = Math.floor(i / PAGES_PER_SEGMENT)
316
320
  const s = this._segments.get(k) || this._segments.set(k, new RemoteBitfieldSegment(k))
321
+ if (this._maxSegments <= k) this._maxSegments = k + 1
317
322
 
318
323
  p = this._pages.set(i, new RemoteBitfieldPage(i, new Uint32Array(WORDS_PER_PAGE), s))
319
324
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.31.8",
3
+ "version": "10.31.9",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {