Skip to content

Commit 66b98b8

Browse files
committed
fix get_node_statistics
1 parent 75a46ad commit 66b98b8

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

mytoncore/mytoncore.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -3047,18 +3047,19 @@ def get_node_statistics(self):
30473047
:return: stats for collated/validated blocks since round beggining and stats for ls queries for the last minute
30483048
"""
30493049
stats = self.local.db.get('statistics', {}).get('node')
3050-
result = {
3051-
'collated': {
3052-
'ok': 0,
3053-
'error': 0,
3054-
},
3055-
'validated': {
3056-
'ok': 0,
3057-
'error': 0,
3058-
}
3059-
}
3050+
result = {}
30603051
if stats is not None and len(stats) == 3 and stats[0] is not None:
30613052
for k in ['master', 'shard']:
3053+
result = {
3054+
'collated': {
3055+
'ok': 0,
3056+
'error': 0,
3057+
},
3058+
'validated': {
3059+
'ok': 0,
3060+
'error': 0,
3061+
}
3062+
}
30623063
collated_ok = stats[2]['collated_blocks'][k]['ok'] - stats[0]['collated_blocks'][k]['ok']
30633064
collated_error = stats[2]['collated_blocks'][k]['error'] - stats[0]['collated_blocks'][k]['error']
30643065
validated_ok = stats[2]['validated_blocks'][k]['ok'] - stats[0]['validated_blocks'][k]['ok']
@@ -3075,7 +3076,7 @@ def get_node_statistics(self):
30753076
result['collated']['error'] += collated_error
30763077
result['validated']['ok'] += validated_ok
30773078
result['validated']['error'] += validated_error
3078-
if stats is not None and len(stats) >= 2:
3079+
if stats is not None and len(stats) >= 2 and stats[0] is not None:
30793080
result['ls_queries'] = {
30803081
'ok': stats[-1]['ls_queries']['ok'] - stats[-2]['ls_queries']['ok'],
30813082
'error': stats[-1]['ls_queries']['error'] - stats[-2]['ls_queries']['error'],

0 commit comments

Comments
 (0)