hypercore 10.30.2 → 10.30.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/batch.js +9 -0
- package/lib/core.js +5 -1
- package/lib/replicator.js +4 -2
- package/package.json +1 -1
package/lib/batch.js
CHANGED
|
@@ -317,6 +317,15 @@ module.exports = class HypercoreBatch extends EventEmitter {
|
|
|
317
317
|
const flushingLength = Math.min(length - this._sessionLength, this._appends.length)
|
|
318
318
|
if (flushingLength <= 0) return true
|
|
319
319
|
|
|
320
|
+
if (this.session.replicator._upgrade) {
|
|
321
|
+
for (const req of this.session.replicator._upgrade.inflight) {
|
|
322
|
+
// yield to the remote inflight upgrade, TODO: if the remote upgrade fails, retry flushing...
|
|
323
|
+
if (req.upgrade && (req.upgrade.start + req.upgrade.length) > length) {
|
|
324
|
+
return false
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
320
329
|
const batch = this.createTreeBatch(this._sessionLength + flushingLength)
|
|
321
330
|
if (batch === null) return false
|
|
322
331
|
|
package/lib/core.js
CHANGED
|
@@ -707,7 +707,11 @@ module.exports = class Core {
|
|
|
707
707
|
|
|
708
708
|
const batch = this.tree.verifyFullyRemote(proof)
|
|
709
709
|
|
|
710
|
-
|
|
710
|
+
try {
|
|
711
|
+
this._verifyBatchUpgrade(batch, proof.manifest)
|
|
712
|
+
} catch {
|
|
713
|
+
return true
|
|
714
|
+
}
|
|
711
715
|
|
|
712
716
|
const remoteTreeHash = this.crypto.tree(proof.upgrade.nodes)
|
|
713
717
|
const localTreeHash = this.crypto.tree(await this.tree.getRoots(proof.upgrade.length))
|
package/lib/replicator.js
CHANGED
|
@@ -688,8 +688,10 @@ class Peer {
|
|
|
688
688
|
safetyCatch(err)
|
|
689
689
|
if (this.core.closed && !isCriticalError(err)) return
|
|
690
690
|
|
|
691
|
-
|
|
692
|
-
|
|
691
|
+
if (err.code !== 'INVALID_OPERATION') {
|
|
692
|
+
// might be a fork, verify
|
|
693
|
+
this._checkIfConflict(err)
|
|
694
|
+
}
|
|
693
695
|
this.replicator._onnodata(this, req)
|
|
694
696
|
return
|
|
695
697
|
} finally {
|