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:
@@ -327,6 +327,17 @@ impl Client {
|
||||
self.send_server_message(MessageFactory::build_global_recommendations())
|
||||
}
|
||||
|
||||
/// The upload speed the server records for us, once it has reported it.
|
||||
/// It is what the distributed child limit is derived from, and it only
|
||||
/// becomes known after an upload has finished and been reported.
|
||||
#[must_use]
|
||||
pub fn own_average_speed(&self) -> Option<u32> {
|
||||
self.context
|
||||
.read_safe()
|
||||
.ok()
|
||||
.and_then(|ctx| ctx.own_average_speed())
|
||||
}
|
||||
|
||||
/// What we ourselves like and hate, as set through this client. The
|
||||
/// server forgets these when the session ends, so they are re-sent after
|
||||
/// each login.
|
||||
|
||||
Reference in New Issue
Block a user