internal void UpdateTyrantStats()
{
// if we're still being choked, set the time of our last choking
if (IsChoking)
{
RoundsChoked++;
LastChokedTime = DateTime.Now;
}
else
{
RoundsUnchoked++;
if (AmInterested)
{
//if we are interested and unchoked, update last measured download rate, unless it is 0
if (Monitor.DownloadSpeed > 0)
{
_lastMeasuredDownloadRate = Monitor.DownloadSpeed;
_maxObservedDownloadSpeed = Math.Max(_lastMeasuredDownloadRate, _maxObservedDownloadSpeed);
}
}
}
// last rate wasn't sufficient to achieve reciprocation
if (!AmChoking && IsChoking && IsInterested)
// only increase upload rate if he's interested, otherwise he won't request any pieces
{
_uploadRateForRecip = (_uploadRateForRecip*12)/10;
}
// we've been unchoked by this guy for a while....
if (!IsChoking && !AmChoking
&& (DateTime.Now - LastChokedTime).TotalSeconds > 30
&& (DateTime.Now - _lastRateReductionTime).TotalSeconds > 30) // only do rate reduction every 30s
{
_uploadRateForRecip = (_uploadRateForRecip*9)/10;
_lastRateReductionTime = DateTime.Now;
}
}