hypercore 11.6.2 → 11.7.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 CHANGED
@@ -213,7 +213,7 @@ class Hypercore extends EventEmitter {
213
213
  throw SESSION_CLOSED('Cannot make sessions on a closing core')
214
214
  }
215
215
  if (opts.checkout !== undefined && !opts.name && !opts.atom) {
216
- throw new Error('Checkouts are only supported on atoms or named sessions')
216
+ throw ASSERTION('Checkouts are only supported on atoms or named sessions')
217
217
  }
218
218
 
219
219
  const wait = opts.wait === false ? false : this.wait
@@ -249,7 +249,7 @@ class Hypercore extends EventEmitter {
249
249
  }
250
250
 
251
251
  if (!isEncryptionProvider(encryption)) {
252
- throw new Error('Provider does not satisfy HypercoreEncryption interface')
252
+ throw ASSERTION('Provider does not satisfy HypercoreEncryption interface')
253
253
  }
254
254
 
255
255
  this.encryption = encryption
package/lib/replicator.js CHANGED
@@ -705,9 +705,14 @@ class Peer {
705
705
  }
706
706
 
707
707
  const manifest = (msg.manifest && !this.core.compat) ? this.core.header.manifest : null
708
- const proof = await MerkleTree.proof(this.core.state, batch, msg)
709
708
 
710
- return new ProofRequest(msg, proof, block, manifest)
709
+ try {
710
+ const proof = await MerkleTree.proof(this.core.state, batch, msg)
711
+ return new ProofRequest(msg, proof, block, manifest)
712
+ } catch (err) {
713
+ batch.destroy()
714
+ throw err
715
+ }
711
716
  }
712
717
 
713
718
  async onrequest (msg) {
@@ -1340,6 +1345,8 @@ class Peer {
1340
1345
  }
1341
1346
 
1342
1347
  _requestForkProof (f) {
1348
+ if (!this.remoteLength) return
1349
+
1343
1350
  const req = this._makeRequest(false, 0, 0)
1344
1351
 
1345
1352
  req.upgrade = { start: 0, length: this.remoteLength }
@@ -543,7 +543,12 @@ module.exports = class SessionState {
543
543
 
544
544
  tx.setHead(tree)
545
545
 
546
- if (this.isDefault()) await storeBitfieldRange(this.storage, tx, batch.ancestors, batch.length, true)
546
+ if (this.isDefault()) {
547
+ await storeBitfieldRange(this.storage, tx, batch.ancestors, batch.length, true)
548
+ if (this.length === this.core.header.hints.contiguousLength) {
549
+ tx.setHints({ contiguousLength: this.length + values.length })
550
+ }
551
+ }
547
552
 
548
553
  for (let i = 0; i < values.length; i++) {
549
554
  tx.putBlock(this.length + i, values[i])
package/lib/streams.js CHANGED
@@ -8,7 +8,7 @@ class ReadStream extends Readable {
8
8
  this.start = opts.start || 0
9
9
  this.end = typeof opts.end === 'number' ? opts.end : -1
10
10
  this.snapshot = !opts.live && opts.snapshot !== false
11
- this.live = !!opts.live
11
+ this.live = this.end === -1 ? !!opts.live : false
12
12
  }
13
13
 
14
14
  _open (cb) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "11.6.2",
3
+ "version": "11.7.0",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {