hypercore 10.24.8 → 10.24.10

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/core.js CHANGED
@@ -479,6 +479,12 @@ module.exports = class Core {
479
479
  this.bitfield.setRange(entry.bitfield.start, entry.bitfield.length, true)
480
480
  batch.commit()
481
481
 
482
+ if (batch.upgraded) {
483
+ this.header.tree.length = batch.length
484
+ this.header.tree.rootHash = batch.hash()
485
+ this.header.tree.signature = batch.signature
486
+ }
487
+
482
488
  const status = (batch.upgraded ? 0b0001 : 0) | updateContig(this.header, entry.bitfield, this.bitfield)
483
489
  this.onupdate(status, entry.bitfield, null, null)
484
490
 
package/lib/replicator.js CHANGED
@@ -295,7 +295,6 @@ class Peer {
295
295
  this.dataProcessing = 0
296
296
 
297
297
  this.canUpgrade = true
298
- this.reopenMaybe = false
299
298
 
300
299
  this.needsSync = false
301
300
  this.syncsProcessing = 0
@@ -376,7 +375,6 @@ class Peer {
376
375
  }
377
376
 
378
377
  this.needsSync = false
379
- if (this.replicator.downloading === false) this.reopenMaybe = true
380
378
 
381
379
  this.wireSync.send({
382
380
  fork: this.core.tree.fork,
@@ -421,8 +419,9 @@ class Peer {
421
419
  onclose (isRemote) {
422
420
  // we might have signalled to the remote that we are done (ie not downloading) and the remote might agree on that
423
421
  // if that happens, the channel might be closed by the remote. if so just renegotiate it.
422
+ // TODO: add a CLOSE_REASON to mux to we can make this cleaner...
424
423
  const reopen = isRemote === true && this.remoteOpened === true && this.remoteDownloading === false &&
425
- this.remoteUploading === true && this.replicator.downloading === true && this.reopenMaybe === true
424
+ this.remoteUploading === true && this.replicator.downloading === true
426
425
 
427
426
  if (this.session && !reopen) this.replicator._closeSession(this.session)
428
427
 
@@ -452,7 +451,7 @@ class Peer {
452
451
  this.remoteDownloading = downloading
453
452
  this.remoteHasManifest = hasManifest
454
453
 
455
- if (this.remoteDownloading === false && this.replicator.downloading === false) {
454
+ if (this.remoteDownloading === false && this.replicator.isDownloading() === false) {
456
455
  // idling, shut it down...
457
456
  this.channel.close()
458
457
  return
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hypercore",
3
- "version": "10.24.8",
3
+ "version": "10.24.10",
4
4
  "description": "Hypercore is a secure, distributed append-only log",
5
5
  "main": "index.js",
6
6
  "scripts": {