Skip to content

Commit f5cd1d3

Browse files
committed
update node statistics collecting
wip
1 parent af9cf22 commit f5cd1d3

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

mytoncore/functions.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,22 +315,27 @@ def get_ok_error(value: str):
315315
data['ext_msg_check'] = {'ok': ok, 'error': error}
316316
if 'total.ls_queries_ok' in status and 'total.ls_queries_error' in status:
317317
data['ls_queries'] = {}
318-
for k in status['total.ls_queries_ok']:
318+
for k in status['total.ls_queries_ok'].split():
319319
if k.startswith('TOTAL'):
320-
data['ls_queries']['ok'] = k.split(':')[1]
321-
for k in status['total.ls_queries_error']:
320+
data['ls_queries']['ok'] = int(k.split(':')[1])
321+
for k in status['total.ls_queries_error'].split():
322322
if k.startswith('TOTAL'):
323-
data['ls_queries']['error'] = k.split(':')[1]
323+
data['ls_queries']['error'] = int(k.split(':')[1])
324324
statistics = local.db.get("statistics", dict())
325325

326326
# statistics['node'] = [stats_from_election_id, stats_from_prev_min, stats_now]
327327

328-
election_id = ton.GetConfig32()['startWorkTime']
329-
if 'node' not in statistics or len(statistics['node']) < 1:
330-
statistics['node'] = [data]
331-
elif statistics['node'][0]['timestamp'] < election_id:
332-
statistics['node'] = [data, data]
333-
else:
328+
election_id = ton.GetConfig34()['startWorkTime']
329+
if 'node' not in statistics or len(statistics['node']) == 0:
330+
statistics['node'] = [None, data]
331+
elif len(statistics['node']) < 3:
332+
statistics['node'].append(data)
333+
if len(statistics['node']) == 3:
334+
if statistics['node'][0] is None:
335+
if 0 < data['timestamp'] - election_id < 90:
336+
statistics['node'][0] = data
337+
elif statistics['node'][0]['timestamp'] < election_id:
338+
statistics['node'][0] = data
334339
statistics['node'] = statistics.get('node', []) + [data]
335340
statistics['node'].pop(1)
336341
local.db["statistics"] = statistics

0 commit comments

Comments
 (0)