aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-28 22:38:41 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-28 22:38:41 +0200
commitaaa372f862ffb7fd093da699e483c9118381e2cc (patch)
tree0f3b2949c6b02ec249728737727f20a403fd8004 /packages
parent7cec0e9199753e11b95500da14d3fd89835e1aa3 (diff)
downloadmeshbay-aaa372f862ffb7fd093da699e483c9118381e2cc.tar.gz
refactor: drop the unread transfer_limits field from the handshake ack
The interface reads a member's cap from transfer_state and never read the copy on the ack. The transfer probe reads it from transfer_state too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/transport.js9
-rw-r--r--packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py14
-rwxr-xr-xpackages/meshbay-node/tests/transfer_probe.py29
3 files changed, 17 insertions, 35 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/transport.js b/packages/meshbay-hub/src/meshbay_hub/static/transport.js
index 7f1b232..98d010e 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/transport.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/transport.js
@@ -500,11 +500,6 @@ class MeshBayTransport {
this._inFlightUploads = new Set();
// tr → Lease. A transfer's slot on the node, from the client's side.
this._leases = new Map();
- // Set from the handshake ack: a node that answers with `transfer_limits`
- // speaks transfer slots. Used instead of a timeout, because "no answer
- // yet" and "this node will never answer" are indistinguishable in time and
- // guessing wrong either stalls every download or defeats the cap.
- this._transferLimits = null;
// Set once close() runs — stops the automatic reconnect from firing on a
// connection the caller tore down on purpose (leaving the group, page
// unload), which would otherwise race back in right as everything else
@@ -573,9 +568,6 @@ class MeshBayTransport {
set onIndexDelta(fn) { this._onIndexDelta = fn; }
set onRootsChanged(fn) { this._onRootsChanged = fn; }
- /** This member's own caps in this group, or null when the node said nothing. */
- get transferLimits() { return this._transferLimits; }
-
set onAppsEnabled(fn) { this._onAppsEnabled = fn; }
set onAppDirectories(fn) { this._onAppDirectories = fn; }
set onChatDirectory(fn) { this._onChatDirectory = fn; }
@@ -1157,7 +1149,6 @@ class MeshBayTransport {
delete ack.nonce;
delete ack.ct;
Object.assign(ack, config);
- this._transferLimits = ack.transfer_limits || null;
// From the *sealed* part of the ack: a forged epoch would have this
// client sealing under a key the group has retired.
diff --git a/packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py b/packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py
index eceb2b4..f701072 100644
--- a/packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py
+++ b/packages/meshbay-node/src/meshbay_node/transport/webrtc/handshake.py
@@ -24,7 +24,6 @@ from meshbay_common.handshake import (
)
from meshbay_common.protocol import MNP
-from meshbay_node import transfers as transfers_mod
from meshbay_node.indexer.indexer import DirectoryIndexer
from meshbay_node.transport.webrtc.channel import _extract_dtls_fingerprint, _get_remote_ip
from meshbay_node.transport.webrtc.limits import MAX_MSG
@@ -266,19 +265,6 @@ class HandshakeMixin:
# No `chat_encrypted` beside it: there is no switch. A peer that
# reached this point speaks MNP 2.0, and 2.0 has no plaintext chat.
"chat_epoch": int(self._group_ctx().get("chat_epoch", 0) or 0),
- # This member's own transfer caps in this group, so the interface
- # can say "2 of 2 of your slots are busy" rather than draw a bare
- # spinner. Absent reads as "no limit known" and the hint is simply
- # not drawn — never as "unlimited", which would have the interface
- # contradicting the node.
- "transfer_limits": {
- "download": self._slots().member_cap(
- transfers_mod.DOWNLOAD,
- (self._group_id or "", self._user_id or "")),
- "upload": self._slots().member_cap(
- transfers_mod.UPLOAD,
- (self._group_id or "", self._user_id or "")),
- },
# So a client that connects mid-scan shows the indexing state
# immediately, instead of waiting for the next periodic
# INDEX_PROGRESS push. Never a path or filename — see
diff --git a/packages/meshbay-node/tests/transfer_probe.py b/packages/meshbay-node/tests/transfer_probe.py
index 7aa4902..6666960 100755
--- a/packages/meshbay-node/tests/transfer_probe.py
+++ b/packages/meshbay-node/tests/transfer_probe.py
@@ -274,7 +274,14 @@ async def operator_checks(client, ack, group, node_id) -> int:
import re as _re
failures = 0
- member_cap = int((ack.get("transfer_limits") or {}).get("download") or 0)
+ # This member's own cap, as the node states it on every `transfer_state`.
+ probe_tr, probe_state = await _open_transfer(client)
+ member_cap = int(probe_state.get("cap") or 0)
+ client.send({"type": "transfer_close", "v": "0.1", "tr": probe_tr, "reason": "done"})
+ while True: # closed before anything below counts what is in use
+ reply = await client.recv_type("transfer_state", timeout=15)
+ if reply.get("tr") == probe_tr and reply.get("state") == "closed":
+ break
# The queue has to be held by the *node* cap, not by this member's own.
#
@@ -446,16 +453,6 @@ async def probe(args) -> int:
ack = await alice.connect(http, group["id"], node_id)
- limits = ack.get("transfer_limits")
- if limits is None:
- print("This node does not hand out transfer slots — it predates "
- "them, or the handshake ack lost the field. Nothing below "
- "can be measured.")
- await alice.close()
- return 1
- cap = int(limits.get("download") or 0)
- print(f"node reports this member may run {cap} download(s) at once\n")
-
if args.operator:
return await operator_checks(alice, ack, group, node_id)
@@ -472,9 +469,17 @@ async def probe(args) -> int:
# held. So the first reply is read for what the node says is already
# in use, and the run stops rather than measuring against a moving
# floor.
- want = args.want or (cap + 2)
opened = [await _open_transfer(alice)]
first = opened[0][1]
+ # This member's cap, as the node states it on every `transfer_state`.
+ cap = int(first.get("cap") or 0)
+ if not cap:
+ print("This node does not state a transfer cap — nothing below can "
+ "be measured.")
+ await alice.close()
+ return 1
+ print(f"node reports this member may run {cap} download(s) at once\n")
+ want = args.want or (cap + 2)
if first.get("state") != "granted" or first.get("used", 1) != 1:
print(f"this node is not idle: it reports {first.get('used')} of "
f"{first.get('cap')} slots already used by this member, and "