hypercore 11.0.33 → 11.0.35
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/remote-bitfield.js +1 -1
- package/lib/session-state.js +3 -0
- package/package.json +1 -1
package/lib/remote-bitfield.js
CHANGED
|
@@ -203,7 +203,7 @@ module.exports = class RemoteBitfield {
|
|
|
203
203
|
p = this._pages.set(i, new RemoteBitfieldPage(i, new Uint32Array(WORDS_PER_PAGE), s))
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
const offset =
|
|
206
|
+
const offset = i * BITS_PER_PAGE
|
|
207
207
|
const last = Math.min(end - offset, BITS_PER_PAGE)
|
|
208
208
|
const range = last - j
|
|
209
209
|
|
package/lib/session-state.js
CHANGED
|
@@ -367,6 +367,9 @@ module.exports = class SessionState {
|
|
|
367
367
|
if (this.prologue && length < this.prologue.length) {
|
|
368
368
|
throw INVALID_OPERATION('Truncation breaks prologue')
|
|
369
369
|
}
|
|
370
|
+
if (length > this.length) {
|
|
371
|
+
throw INVALID_OPERATION('Not a truncation, ' + length + ' must be less or equal to ' + this.length)
|
|
372
|
+
}
|
|
370
373
|
|
|
371
374
|
const batch = this.createTreeBatch()
|
|
372
375
|
await MerkleTree.truncate(this, length, batch, fork)
|