blind-peer 3.8.1 → 3.8.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/index.js +11 -3
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -55,6 +55,8 @@ class CoreTracker {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
_onupdate() {
|
|
58
|
+
if (this.blindPeer.closing) return
|
|
59
|
+
|
|
58
60
|
this.updated = true
|
|
59
61
|
if (!this.record) return
|
|
60
62
|
|
|
@@ -65,6 +67,8 @@ class CoreTracker {
|
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
_onactive() {
|
|
70
|
+
if (this.blindPeer.closing) return
|
|
71
|
+
|
|
68
72
|
this.activated = true
|
|
69
73
|
|
|
70
74
|
if (this.record) {
|
|
@@ -94,6 +98,7 @@ class CoreTracker {
|
|
|
94
98
|
}
|
|
95
99
|
|
|
96
100
|
async refresh() {
|
|
101
|
+
if (this.destroyed || this.record) return
|
|
97
102
|
await this.core.ready()
|
|
98
103
|
if (this.destroyed) return
|
|
99
104
|
|
|
@@ -104,7 +109,7 @@ class CoreTracker {
|
|
|
104
109
|
if (this.destroyed || this.record || !record) return
|
|
105
110
|
|
|
106
111
|
this.record = record
|
|
107
|
-
this.core.download({ start: this.record.blocksCleared, end: -1 })
|
|
112
|
+
this.downloadRange = this.core.download({ start: this.record.blocksCleared, end: -1 })
|
|
108
113
|
|
|
109
114
|
if (this.updated) this._onupdate()
|
|
110
115
|
if (this.activated) this._onactive()
|
|
@@ -140,6 +145,7 @@ class CoreTracker {
|
|
|
140
145
|
destroy() {
|
|
141
146
|
if (this.destroyed) return
|
|
142
147
|
this.destroyed = true
|
|
148
|
+
this.downloadRange.destroy()
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
151
|
|
|
@@ -435,7 +441,7 @@ class BlindPeer extends ReadyResource {
|
|
|
435
441
|
|
|
436
442
|
try {
|
|
437
443
|
const tracker = this.activeReplication.get(id)
|
|
438
|
-
|
|
444
|
+
await tracker.refresh()
|
|
439
445
|
const coreBytesCleared = tracker.gc()
|
|
440
446
|
bytesCleared += coreBytesCleared
|
|
441
447
|
} finally {
|
|
@@ -572,7 +578,7 @@ class BlindPeer extends ReadyResource {
|
|
|
572
578
|
await core.ready()
|
|
573
579
|
|
|
574
580
|
const tracker = this.activeReplication.get(b4a.toString(core.discoveryKey, 'hex'))
|
|
575
|
-
if (tracker
|
|
581
|
+
if (tracker) await tracker.refresh()
|
|
576
582
|
|
|
577
583
|
if (record.announce) {
|
|
578
584
|
await this._announceCore(core.key)
|
|
@@ -626,6 +632,7 @@ class BlindPeer extends ReadyResource {
|
|
|
626
632
|
let activeSession = null
|
|
627
633
|
|
|
628
634
|
core.on('append', () => {
|
|
635
|
+
if (this.closing) return
|
|
629
636
|
const replicationLag = core.length - core.contiguousLength
|
|
630
637
|
if (!activeSession.isClient && replicationLag > this.replicationLagThreshold) {
|
|
631
638
|
activeSession.refresh({ server: true, client: true })
|
|
@@ -635,6 +642,7 @@ class BlindPeer extends ReadyResource {
|
|
|
635
642
|
this.emit('core-append', core)
|
|
636
643
|
})
|
|
637
644
|
core.on('download', () => {
|
|
645
|
+
if (this.closing) return
|
|
638
646
|
const replicationLag = core.length - core.contiguousLength
|
|
639
647
|
if (replicationLag === 0) {
|
|
640
648
|
if (activeSession.isClient) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blind-peer",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.2",
|
|
4
4
|
"description": "Blind peers help keep hypercores available",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"bare-process": "^4.2.2",
|
|
35
35
|
"bare-prom-client": "^15.1.3",
|
|
36
36
|
"blind-peer-router": "^0.2.2",
|
|
37
|
-
"blind-peering": "^2.1.
|
|
37
|
+
"blind-peering": "^2.1.2",
|
|
38
38
|
"brittle": "^3.7.0",
|
|
39
39
|
"debounceify": "^1.1.0",
|
|
40
40
|
"graceful-goodbye": "^1.3.3",
|