Fix incorrect counting of total bytes sent / received

This commit is contained in:
Miroslav Kovar 2019-10-04 15:46:36 +02:00 committed by Lex Berezhny
parent f5fed54195
commit 2883c6bab3

View file

@ -19,8 +19,6 @@ class ConnectionManager:
self.outgoing_connected: typing.Set[str] = set() self.outgoing_connected: typing.Set[str] = set()
self.outgoing: typing.DefaultDict[str, int] = collections.defaultdict(int) self.outgoing: typing.DefaultDict[str, int] = collections.defaultdict(int)
self._status = {} self._status = {}
self._total_sent = 0
self._total_received = 0
self._running = False self._running = False
self._task: typing.Optional[asyncio.Task] = None self._task: typing.Optional[asyncio.Task] = None
@ -58,8 +56,8 @@ class ConnectionManager:
'outgoing_bps': {}, 'outgoing_bps': {},
'total_incoming_mbs': 0.0, 'total_incoming_mbs': 0.0,
'total_outgoing_mbs': 0.0, 'total_outgoing_mbs': 0.0,
'total_sent': self._total_sent, 'total_sent': 0,
'total_received': self._total_received, 'total_received': 0,
'time': self.loop.time() 'time': self.loop.time()
} }
@ -79,8 +77,8 @@ class ConnectionManager:
) / (now - last)) / 1000000.0 ) / (now - last)) / 1000000.0
self._status['total_incoming_mbs'] = int(sum(list(self._status['incoming_bps'].values()) self._status['total_incoming_mbs'] = int(sum(list(self._status['incoming_bps'].values())
) / (now - last)) / 1000000.0 ) / (now - last)) / 1000000.0
self._total_sent += sum(list(self._status['outgoing_bps'].values())) self._status['total_sent'] += sum(list(self._status['outgoing_bps'].values()))
self._total_received += sum(list(self._status['incoming_bps'].values())) self._status['total_received'] += sum(list(self._status['incoming_bps'].values()))
self._status['time'] = now self._status['time'] = now