feat(distributed): learn our own upload speed by watching ourselves

The child limit is derived from the upload speed the server records for
us, and the server pushes a user's stats to whoever watches that user —
so a client that does not watch itself never learns its own figure and
would carry the default cap forever. Nicotine+ reads the same number off
the stats the server sends about the logged-in user.

We now watch ourselves as each session starts, and the stats that come
back — the initial reply and every later push — set the figure the limit
is derived from. Client::own_average_speed exposes it.
This commit is contained in:
Michel de Graaf
2026-09-09 17:11:04 +00:00
parent 773b5a4100
commit 6d6f4f282e
4 changed files with 146 additions and 22 deletions
+6
View File
@@ -821,6 +821,12 @@ impl ClientContext {
self.own_interests.clone()
}
/// The upload speed the server records for us, if it has said.
#[must_use]
pub const fn own_average_speed(&self) -> Option<u32> {
self.own_average_speed
}
/// Record what the server says our own upload speed is, and re-derive the
/// child limit from it.
pub fn set_own_average_speed(&mut self, speed: u32) {