Universal.Torrent.Client.PeerConnections.PeerId.GetDownloadRate C# (CSharp) Method

GetDownloadRate() private method

Get our download rate from this peer -- this is Dp. 1. If we are not choked by this peer, return the actual measure download rate. 2. If we are choked, then attempt to make an educated guess at the download rate using the following steps - use the rate of Have messages received from this peer as an estimate of its download rate - assume that its upload rate is equivalent to its estimated download rate - divide this upload rate by the standard implementation's active set size for that rate
private GetDownloadRate ( ) : int
return int
        internal int GetDownloadRate()
        {
            if (_lastMeasuredDownloadRate > 0)
            {
                return _lastMeasuredDownloadRate;
            }
            // assume that his upload rate will match his estimated download rate, and 
            // get the estimated active set size
            var estimatedDownloadRate = EstimatedDownloadRate;
            var activeSetSize = GetActiveSetSize(estimatedDownloadRate);

            return estimatedDownloadRate/activeSetSize;
        }