hypercore 11.27.3 → 11.27.4
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/session-state.js +28 -4
- package/package.json +1 -1
package/lib/session-state.js
CHANGED
|
@@ -583,12 +583,20 @@ class SessionState {
|
|
|
583
583
|
continue
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
|
|
586
|
+
let restart = false
|
|
587
587
|
|
|
588
|
-
|
|
588
|
+
for (let i = 0; i < 32; i++) {
|
|
589
|
+
await new Promise((resolve) => setTimeout(resolve, 250))
|
|
589
590
|
|
|
590
|
-
|
|
591
|
-
|
|
591
|
+
peers = getRecoveryPeers(replicator.peers)
|
|
592
|
+
|
|
593
|
+
if (this.closing || !validateRecoveryPeers(peers, this.length)) {
|
|
594
|
+
restart = true
|
|
595
|
+
break
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (restart) continue
|
|
592
600
|
|
|
593
601
|
if (this.length !== length) {
|
|
594
602
|
throw SESSION_NOT_WRITABLE('core recovered during append')
|
|
@@ -1310,3 +1318,19 @@ function getRecoveryPeers(peers) {
|
|
|
1310
1318
|
|
|
1311
1319
|
return actual
|
|
1312
1320
|
}
|
|
1321
|
+
|
|
1322
|
+
function validateRecoveryPeers(peers, length) {
|
|
1323
|
+
if (peers.length < 1) return false
|
|
1324
|
+
|
|
1325
|
+
for (const p of peers) {
|
|
1326
|
+
if (p.remoteLength > length) return false
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
let all = true
|
|
1330
|
+
|
|
1331
|
+
for (const p of peers) {
|
|
1332
|
+
if (p.remoteLength === 0) all = false
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
return all
|
|
1336
|
+
}
|