@torrent-tv/proxy 2.69.2 → 2.71.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/CHANGELOG.md +28 -0
- package/CLAUDE.md +12 -0
- package/docs/download-architecture.md +175 -0
- package/docs/logs.md +8 -0
- package/package.json +1 -1
- package/services/demand/DemandRegister.js +182 -0
- package/services/demand/Urgency.js +137 -0
- package/services/demand/Window.js +118 -0
- package/services/demand/index.js +11 -0
- package/services/demand/pieces.js +140 -0
- package/services/download/SwarmSelection.js +313 -0
- package/services/download/index.js +8 -0
- package/services/download/registry.js +96 -0
- package/services/piece-store/piece-lru.js +30 -0
- package/services/piece-store/shared-piece-store.js +494 -34
- package/services/torrent-pool.js +64 -197
- package/services/torrent-worker/fastest-wires.js +319 -279
- package/services/torrent-worker/piece-reader.js +146 -178
- package/services/torrent-worker/worker.js +75 -14
- package/test/demand-register.test.js +195 -0
- package/test/fastest-wires.test.js +23 -1
- package/test/memory-budget.test.js +73 -29
- package/test/piece-store-eviction.test.js +220 -0
- package/test/read-bands.test.js +17 -10
- package/test/read-window.test.js +20 -8
- package/test/swarm-selection.test.js +191 -0
- package/utils/logger.js +62 -20
|
@@ -248,6 +248,36 @@ export class PieceLru {
|
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Whether a reader is holding this piece right now.
|
|
253
|
+
*
|
|
254
|
+
* Asked before a block is put back for re-use: a pinned piece has a view onto
|
|
255
|
+
* its memory somewhere, and handing that memory to another piece would let
|
|
256
|
+
* the holder read bytes that are not its own.
|
|
257
|
+
*
|
|
258
|
+
* @param {number} index
|
|
259
|
+
* @returns {boolean}
|
|
260
|
+
*/
|
|
261
|
+
isPinned(index) {
|
|
262
|
+
return this.#pins.has(index);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Whether any live reader has declared it will want this piece.
|
|
267
|
+
*
|
|
268
|
+
* Asked on admission, not only on eviction: a piece nobody has declared is
|
|
269
|
+
* being downloaded ahead of every reader, and putting it in memory means
|
|
270
|
+
* pushing out one that IS declared — which is then read back from disk
|
|
271
|
+
* moments later. Measured 2026-09-02: 6565 spills and 7575 revivals in 44
|
|
272
|
+
* minutes with 53.6 % of reads served from memory (roadmap item 9).
|
|
273
|
+
*
|
|
274
|
+
* @param {number} index
|
|
275
|
+
* @returns {boolean}
|
|
276
|
+
*/
|
|
277
|
+
wants(index) {
|
|
278
|
+
return this.#isProtected(index);
|
|
279
|
+
}
|
|
280
|
+
|
|
251
281
|
/**
|
|
252
282
|
* Pieces from `index` to the nearest declared window, zero inside one and -1
|
|
253
283
|
* when nothing is declared.
|