hypercore 11.1.2 → 11.2.0
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 +7 -4
- package/package.json +1 -1
package/lib/replicator.js
CHANGED
|
@@ -1109,7 +1109,9 @@ class Peer {
|
|
|
1109
1109
|
: { start: this.core.state.length, length: this.remoteLength - this.core.state.length },
|
|
1110
1110
|
// remote manifest check can be removed eventually...
|
|
1111
1111
|
manifest: this.core.header.manifest === null && this.remoteHasManifest === true,
|
|
1112
|
-
priority
|
|
1112
|
+
priority,
|
|
1113
|
+
timestamp: Date.now(),
|
|
1114
|
+
elapsed: 0
|
|
1113
1115
|
}
|
|
1114
1116
|
}
|
|
1115
1117
|
|
|
@@ -2097,9 +2099,10 @@ module.exports = class Replicator {
|
|
|
2097
2099
|
}
|
|
2098
2100
|
|
|
2099
2101
|
_ondata (peer, req, data) {
|
|
2102
|
+
req.elapsed = Date.now() - req.timestamp
|
|
2100
2103
|
if (data.block !== null) {
|
|
2101
2104
|
this._resolveBlockRequest(this._blocks, data.block.index, data.block.value, req)
|
|
2102
|
-
this._ondownload(data.block.index, data.block.value.byteLength, peer)
|
|
2105
|
+
this._ondownload(data.block.index, data.block.value.byteLength, peer, req)
|
|
2103
2106
|
}
|
|
2104
2107
|
|
|
2105
2108
|
if (data.hash !== null && (data.hash.index & 1) === 0) {
|
|
@@ -2492,12 +2495,12 @@ module.exports = class Replicator {
|
|
|
2492
2495
|
}
|
|
2493
2496
|
}
|
|
2494
2497
|
|
|
2495
|
-
_ondownload (index, byteLength, from) {
|
|
2498
|
+
_ondownload (index, byteLength, from, req) {
|
|
2496
2499
|
const sessions = this.core.monitors
|
|
2497
2500
|
|
|
2498
2501
|
for (let i = sessions.length - 1; i >= 0; i--) {
|
|
2499
2502
|
const s = sessions[i]
|
|
2500
|
-
s.emit('download', index, byteLength - s.padding, from)
|
|
2503
|
+
s.emit('download', index, byteLength - s.padding, from, req)
|
|
2501
2504
|
}
|
|
2502
2505
|
}
|
|
2503
2506
|
|