summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src')
-rw-r--r--packages/meshbay-node/src/meshbay_node/transfers.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/transfers.py b/packages/meshbay-node/src/meshbay_node/transfers.py
index 2185547..dd382b4 100644
--- a/packages/meshbay-node/src/meshbay_node/transfers.py
+++ b/packages/meshbay-node/src/meshbay_node/transfers.py
@@ -417,9 +417,28 @@ class TransferSlots:
# takes a slot.
#
# But "not leased" cannot mean "unbounded", or a client that simply omits `tr`
-# transfers outside every cap and the caps are decoration. Two, because a viewer
-# looks at *one* file — one photo, one document — and the second is there so
-# that prefetching the next photo stays possible.
+# transfers outside every cap and the caps are decoration.
+#
+# **The number comes from what the shipped client legitimately does, and it was
+# wrong once already.** §3.4.1 of ~/next/improve-downloads.md argued for two,
+# reasoning about *viewers*: a photo viewer shows one photo, a preview modal one
+# document, and the second is for prefetching the next photo. That reasoning
+# forgot the music player, which warms a read-ahead window — `prefetchDepth()`
+# in music-player.js returns 5 on Wi-Fi, 3 otherwise — so playing an album has
+# six files in flight and the fourth was refused with `transfer_required`.
+# Reported the day MNP 3.0 shipped, as "I try to play a track and it tells me to
+# download it instead".
+#
+# Twelve: six for the music read-ahead at its widest, two for a photo viewer
+# and its own prefetch running at the same time in the same session, and the
+# rest as headroom for the next app that reads ahead. `test_leaseless_reads.py`
+# derives the floor from music-player.js itself, so raising the client's
+# prefetch without raising this fails rather than reaching a person.
+#
+# Generosity is cheap here and refusal is not. This is a fairness control among
+# cooperating clients, not a security boundary — a client that lies gets twelve
+# files at a time instead of its member cap, which is bounded and audited —
+# whereas refusing a legitimate read breaks a stated requirement.
#
# Deliberately a count of files and not a byte budget: a RAW photo out of a
# camera is 60-80 MB and is browsing, a 40 MB archive is a download, and no
@@ -431,7 +450,7 @@ class TransferSlots:
# as the cap itself. **This is a fairness control among cooperating clients**,
# not a defence against a member determined to saturate a node's disk. The
# answer to that member is `member revoke`.
-MAX_LEASELESS_IN_FLIGHT = 2
+MAX_LEASELESS_IN_FLIGHT = 12
# A leaseless read has no "close" message, so it ends when the last chunk goes
# out — or, when a viewer is closed mid-file and simply stops asking, when it