'function to update swarm statistics.
This function called when we get new Downloadstate for active torrents.
Updated downloadstate (seeding_stats) for a particular torrent is stored here.'

def update_torrent_stats(self, torrent_infohash_str, seeding_stats):

    if ('time_seeding' in self.torrents[torrent_infohash_str]['last_seeding_stats']):
        if (seeding_stats['time_seeding'] >= self.torrents[torrent_infohash_str]['last_seeding_stats']['time_seeding']):
            self.torrents[torrent_infohash_str]['last_seeding_stats'] = seeding_stats
    else:
        self.torrents[torrent_infohash_str]['last_seeding_stats'] = seeding_stats
