hypercore 10.22.1 → 10.22.2
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/replicator.js +12 -1
- package/package.json +1 -1
package/lib/replicator.js
CHANGED
|
@@ -295,6 +295,7 @@ class Peer {
|
|
|
295
295
|
this.dataProcessing = 0
|
|
296
296
|
|
|
297
297
|
this.canUpgrade = true
|
|
298
|
+
this.reopenMaybe = false
|
|
298
299
|
|
|
299
300
|
this.needsSync = false
|
|
300
301
|
this.syncsProcessing = 0
|
|
@@ -375,6 +376,7 @@ class Peer {
|
|
|
375
376
|
}
|
|
376
377
|
|
|
377
378
|
this.needsSync = false
|
|
379
|
+
if (this.replicator.downloading === false) this.reopenMaybe = true
|
|
378
380
|
|
|
379
381
|
this.wireSync.send({
|
|
380
382
|
fork: this.core.tree.fork,
|
|
@@ -417,7 +419,12 @@ class Peer {
|
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
onclose (isRemote) {
|
|
420
|
-
|
|
422
|
+
// we might have signalled to the remote that we are done (ie not downloading) and the remote might agree on that
|
|
423
|
+
// if that happens, the channel might be closed by the remote. if so just renegotiate it.
|
|
424
|
+
const reopen = isRemote === true && this.remoteOpened === true && this.remoteDownloading === false &&
|
|
425
|
+
this.remoteUploading === true && this.replicator.downloading === true && this.reopenMaybe === true
|
|
426
|
+
|
|
427
|
+
if (this.session && !reopen) this.replicator._closeSession(this.session)
|
|
421
428
|
|
|
422
429
|
if (this.remoteOpened === false) {
|
|
423
430
|
this.replicator._ifAvailable--
|
|
@@ -427,6 +434,10 @@ class Peer {
|
|
|
427
434
|
|
|
428
435
|
this.remoteOpened = false
|
|
429
436
|
this.replicator._removePeer(this)
|
|
437
|
+
|
|
438
|
+
if (reopen) {
|
|
439
|
+
this.replicator._makePeer(this.protomux, this.session)
|
|
440
|
+
}
|
|
430
441
|
}
|
|
431
442
|
|
|
432
443
|
async onsync ({ fork, length, remoteLength, canUpgrade, uploading, downloading }) {
|