OctoTorrent.Client.PeerId.UpdateTyrantStats C# (CSharp) Method

UpdateTyrantStats() private method

Should be called by ChokeUnchokeManager.ExecuteReview Logic taken from BitTyrant implementation
private UpdateTyrantStats ( ) : void
return void
        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;
            }
        }