hypercore 10.29.1 → 10.29.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 +13 -7
- package/package.json +1 -1
package/lib/replicator.js
CHANGED
|
@@ -1059,12 +1059,22 @@ class Peer {
|
|
|
1059
1059
|
}
|
|
1060
1060
|
}
|
|
1061
1061
|
|
|
1062
|
+
isActive () {
|
|
1063
|
+
if (this.paused || this.removed) return false
|
|
1064
|
+
return true
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1062
1067
|
async _send (req) {
|
|
1063
1068
|
const fork = this.core.tree.fork
|
|
1064
1069
|
|
|
1065
1070
|
this.inflight++
|
|
1066
1071
|
this.replicator._inflight.add(req)
|
|
1067
1072
|
|
|
1073
|
+
if (req.upgrade !== null && req.fork === fork) {
|
|
1074
|
+
const u = this.replicator._addUpgrade()
|
|
1075
|
+
u.inflight.push(req)
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1068
1078
|
try {
|
|
1069
1079
|
if (req.block !== null && req.fork === fork) {
|
|
1070
1080
|
req.block.nodes = await this.core.tree.missingNodes(2 * req.block.index)
|
|
@@ -1084,11 +1094,6 @@ class Peer {
|
|
|
1084
1094
|
return
|
|
1085
1095
|
}
|
|
1086
1096
|
|
|
1087
|
-
if (req.upgrade !== null && req.fork === fork) {
|
|
1088
|
-
const u = this.replicator._addUpgrade()
|
|
1089
|
-
u.inflight.push(req)
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
1097
|
this.wireRequest.send(req)
|
|
1093
1098
|
}
|
|
1094
1099
|
}
|
|
@@ -1414,6 +1419,7 @@ module.exports = class Replicator {
|
|
|
1414
1419
|
|
|
1415
1420
|
_removePeer (peer) {
|
|
1416
1421
|
this.peers.splice(this.peers.indexOf(peer), 1)
|
|
1422
|
+
peer.removed = true
|
|
1417
1423
|
|
|
1418
1424
|
if (this._manifestPeer === peer) this._manifestPeer = null
|
|
1419
1425
|
|
|
@@ -1765,7 +1771,7 @@ module.exports = class Replicator {
|
|
|
1765
1771
|
}
|
|
1766
1772
|
|
|
1767
1773
|
_updatePeer (peer) {
|
|
1768
|
-
if (peer.
|
|
1774
|
+
if (!peer.isActive() || peer.inflight >= peer.getMaxInflight()) {
|
|
1769
1775
|
return false
|
|
1770
1776
|
}
|
|
1771
1777
|
|
|
@@ -1797,7 +1803,7 @@ module.exports = class Replicator {
|
|
|
1797
1803
|
}
|
|
1798
1804
|
|
|
1799
1805
|
_updatePeerNonPrimary (peer) {
|
|
1800
|
-
if (peer.
|
|
1806
|
+
if (!peer.isActive() || peer.inflight >= peer.getMaxInflight()) {
|
|
1801
1807
|
return false
|
|
1802
1808
|
}
|
|
1803
1809
|
|