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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user