hypercore 11.8.2 → 11.9.0
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 +2 -2
- package/lib/core.js +0 -6
- package/lib/replicator.js +3 -0
- package/lib/session-state.js +5 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -920,7 +920,7 @@ class Hypercore extends EventEmitter {
|
|
|
920
920
|
const isDefault = this.state === this.core.state
|
|
921
921
|
const defaultKeyPair = this.state.name === null ? this.keyPair : null
|
|
922
922
|
|
|
923
|
-
const { keyPair = defaultKeyPair, signature = null } = opts
|
|
923
|
+
const { keyPair = defaultKeyPair, signature = null, maxLength } = opts
|
|
924
924
|
const writable = !isDefault || !!signature || !!(keyPair && keyPair.secretKey) || opts.writable === true
|
|
925
925
|
|
|
926
926
|
if (this._readonly || writable === false) throw SESSION_NOT_WRITABLE()
|
|
@@ -942,7 +942,7 @@ class Hypercore extends EventEmitter {
|
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
944
|
|
|
945
|
-
return this.state.append(buffers, { keyPair, signature, preappend })
|
|
945
|
+
return this.state.append(buffers, { keyPair, signature, preappend, maxLength })
|
|
946
946
|
}
|
|
947
947
|
|
|
948
948
|
async signable (length = -1, fork = -1) {
|
package/lib/core.js
CHANGED
|
@@ -170,7 +170,6 @@ module.exports = class Core {
|
|
|
170
170
|
manifest,
|
|
171
171
|
keyPair: keyPair ? { publicKey: keyPair.publicKey, secretKey: keyPair.secretKey || null } : null,
|
|
172
172
|
frozen: false,
|
|
173
|
-
userData: [],
|
|
174
173
|
tree: {
|
|
175
174
|
fork: 0,
|
|
176
175
|
length: 0,
|
|
@@ -254,10 +253,6 @@ module.exports = class Core {
|
|
|
254
253
|
await tx.flush()
|
|
255
254
|
}
|
|
256
255
|
|
|
257
|
-
for await (const { key, value } of storage.createUserDataStream()) {
|
|
258
|
-
header.userData.push({ key, value: unslab(value) })
|
|
259
|
-
}
|
|
260
|
-
|
|
261
256
|
const len = bitfield.findFirst(false, header.hints.contiguousLength)
|
|
262
257
|
if (header.hints.contiguousLength !== len) {
|
|
263
258
|
header.hints.contiguousLength = len
|
|
@@ -797,7 +792,6 @@ function parseHeader (info) {
|
|
|
797
792
|
manifest: info.manifest,
|
|
798
793
|
external: null,
|
|
799
794
|
keyPair: info.keyPair,
|
|
800
|
-
userData: [],
|
|
801
795
|
tree: info.head || getDefaultTree(),
|
|
802
796
|
hints: {
|
|
803
797
|
reorgs: [],
|
package/lib/replicator.js
CHANGED
|
@@ -702,6 +702,7 @@ class Peer {
|
|
|
702
702
|
}
|
|
703
703
|
|
|
704
704
|
block = batch.getBlock(index)
|
|
705
|
+
block.catch(noop)
|
|
705
706
|
}
|
|
706
707
|
|
|
707
708
|
const manifest = (msg.manifest && !this.core.compat) ? this.core.header.manifest : null
|
|
@@ -2676,3 +2677,5 @@ function incrementRx (stats1, stats2) {
|
|
|
2676
2677
|
stats1.rx++
|
|
2677
2678
|
stats2.rx++
|
|
2678
2679
|
}
|
|
2680
|
+
|
|
2681
|
+
function noop () {}
|
package/lib/session-state.js
CHANGED
|
@@ -503,12 +503,16 @@ module.exports = class SessionState {
|
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
async append (values, { signature, keyPair, preappend } = {}) {
|
|
506
|
+
async append (values, { signature, keyPair, preappend, maxLength = -1 } = {}) {
|
|
507
507
|
if (!keyPair && this.isDefault()) keyPair = this.core.header.keyPair
|
|
508
508
|
|
|
509
509
|
await this.mutex.lock()
|
|
510
510
|
|
|
511
511
|
try {
|
|
512
|
+
if (maxLength >= 0 && (this.length + values.length) >= maxLength) {
|
|
513
|
+
return { length: this.length, byteLength: this.byteLength }
|
|
514
|
+
}
|
|
515
|
+
|
|
512
516
|
const tx = this.createWriteBatch()
|
|
513
517
|
|
|
514
518
|
// upsert compat manifest
|