hypercore 11.0.24 → 11.0.26
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/index.js +3 -0
- package/lib/session-state.js +10 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -208,6 +208,9 @@ class Hypercore extends EventEmitter {
|
|
|
208
208
|
// in practice, open an issue and we'll try to make a solution for it.
|
|
209
209
|
throw SESSION_CLOSED('Cannot make sessions on a closing core')
|
|
210
210
|
}
|
|
211
|
+
if (opts.checkout !== undefined && !opts.name && !opts.atom) {
|
|
212
|
+
throw new Error('Checkouts are only supported on atoms or named sessions')
|
|
213
|
+
}
|
|
211
214
|
|
|
212
215
|
const wait = opts.wait === false ? false : this.wait
|
|
213
216
|
const writable = opts.writable === undefined ? !this._readonly : opts.writable === true
|
package/lib/session-state.js
CHANGED
|
@@ -465,6 +465,9 @@ module.exports = class SessionState {
|
|
|
465
465
|
|
|
466
466
|
if (this.isDefault()) {
|
|
467
467
|
await storeBitfieldRange(this.storage, storage, batch.ancestors, batch.treeLength, false)
|
|
468
|
+
if (batch.ancestors < this.core.header.hints.contiguousLength) {
|
|
469
|
+
storage.setHints({ contiguousLength: batch.ancestors })
|
|
470
|
+
}
|
|
468
471
|
}
|
|
469
472
|
|
|
470
473
|
return { dependency, tree, roots: batch.roots }
|
|
@@ -476,7 +479,12 @@ module.exports = class SessionState {
|
|
|
476
479
|
try {
|
|
477
480
|
const tx = this.createWriteBatch()
|
|
478
481
|
|
|
479
|
-
if (this.isDefault())
|
|
482
|
+
if (this.isDefault()) {
|
|
483
|
+
await storeBitfieldRange(this.storage, tx, start, end, false)
|
|
484
|
+
if (start < this.core.header.hints.contiguousLength) {
|
|
485
|
+
tx.setHints({ contiguousLength: start })
|
|
486
|
+
}
|
|
487
|
+
}
|
|
480
488
|
|
|
481
489
|
this.blocks.clear(tx, start, end)
|
|
482
490
|
|
|
@@ -1088,7 +1096,7 @@ async function storeBitfieldRange (storage, tx, from, to, value) {
|
|
|
1088
1096
|
const pageIndex = i + firstPage
|
|
1089
1097
|
if (!pages[i]) pages[i] = b4a.alloc(Bitfield.BYTES_PER_PAGE)
|
|
1090
1098
|
|
|
1091
|
-
index = fillBitfieldPage(pages[i], index, to, pageIndex,
|
|
1099
|
+
index = fillBitfieldPage(pages[i], index, to, pageIndex, value)
|
|
1092
1100
|
tx.putBitfieldPage(pageIndex, pages[i])
|
|
1093
1101
|
}
|
|
1094
1102
|
}
|