Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mytoncore/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def get_ok_error(value: str):

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

election_id = ton.GetConfig34()['startWorkTime']
election_id = ton.GetConfig34(no_cache=True)['startWorkTime']
if 'node' not in statistics or len(statistics['node']) == 0:
statistics['node'] = [None, data]
elif len(statistics['node']) < 3:
Expand All @@ -328,9 +328,11 @@ def get_ok_error(value: str):
statistics['node'][0] = data
elif statistics['node'][0]['timestamp'] < election_id:
statistics['node'][0] = data
statistics['node'] = statistics.get('node', []) + [data]
statistics['node'].pop(1)
temp = statistics.get('node', []) + [data]
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] For a fixed-size rotating buffer of length 3, using a deque with maxlen=3 from collections could simplify rotation logic and improve clarity.

Copilot uses AI. Check for mistakes.
temp.pop(1)
statistics['node'] = temp
local.db["statistics"] = statistics
local.save()


def ReadTransData(local, scanner):
Expand Down
28 changes: 14 additions & 14 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,11 +930,11 @@ def GetConfig32(self):
return config32
#end define

def GetConfig34(self):
def GetConfig34(self, no_cache: bool = False):
# Get buffer
bname = "config34"
buff = self.GetFunctionBuffer(bname, timeout=60)
if buff:
buff = self.GetFunctionBuffer(bname, timeout=10)
if buff and not no_cache:
return buff
#end if

Expand Down Expand Up @@ -3061,17 +3061,17 @@ def get_node_statistics(self):
stats = self.local.db.get('statistics', {}).get('node')
result = {}
if stats is not None and len(stats) == 3 and stats[0] is not None:
for k in ['master', 'shard']:
result = {
'collated': {
'ok': 0,
'error': 0,
},
'validated': {
'ok': 0,
'error': 0,
}
result = {
'collated': {
'ok': 0,
'error': 0,
},
'validated': {
'ok': 0,
'error': 0,
}
}
for k in ['master', 'shard']:
collated_ok = stats[2]['collated_blocks'][k]['ok'] - stats[0]['collated_blocks'][k]['ok']
collated_error = stats[2]['collated_blocks'][k]['error'] - stats[0]['collated_blocks'][k]['error']
validated_ok = stats[2]['validated_blocks'][k]['ok'] - stats[0]['validated_blocks'][k]['ok']
Expand All @@ -3088,7 +3088,7 @@ def get_node_statistics(self):
result['collated']['error'] += collated_error
result['validated']['ok'] += validated_ok
result['validated']['error'] += validated_error
if stats is not None and len(stats) >= 2 and stats[0] is not None:
if stats is not None and len(stats) >= 2 and stats[-2] is not None and stats[-1] is not None:
result['ls_queries'] = {
'ok': stats[-1]['ls_queries']['ok'] - stats[-2]['ls_queries']['ok'],
'error': stats[-1]['ls_queries']['error'] - stats[-2]['ls_queries']['error'],
Expand Down
28 changes: 15 additions & 13 deletions mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,23 +774,25 @@ def PrintLocalStatus(local, ton, adnlAddr, validatorIndex, validatorEfficiency,

active_validator_groups = None

if ton.using_validator() and validator_status.validator_groups_master and validator_status.validator_groups_shard:
if ton.using_validator() and validator_status.validator_groups_master is not None and validator_status.validator_groups_shard is not None:
active_validator_groups = local.translate("active_validator_groups").format(validator_status.validator_groups_master, validator_status.validator_groups_shard)

collated, validated = None, None
ls_queries = None
if ton.using_validator():
node_stats = ton.get_node_statistics()
if node_stats and 'collated' in node_stats and 'validated' in node_stats:
collated = local.translate('collated_blocks').format(node_stats['collated']['ok'], node_stats['collated']['error'])
validated = local.translate('validated_blocks').format(node_stats['validated']['ok'], node_stats['validated']['error'])
else:
collated = local.translate('collated_blocks').format('collecting data...', 'wait for the next validation round')
validated = local.translate('validated_blocks').format('collecting data...', 'wait for the next validation round')
if ton.using_liteserver():
node_stats = ton.get_node_statistics()
if node_stats and 'ls_queries' in node_stats:
ls_queries = local.translate('ls_queries').format(node_stats['ls_queries']['time'], node_stats['ls_queries']['ok'], node_stats['ls_queries']['error'])
node_stats = local.try_function(ton.get_node_statistics)
if node_stats is not None:
if ton.using_validator():
if 'collated' in node_stats and 'validated' in node_stats:
collated = local.translate('collated_blocks').format(node_stats['collated']['ok'], node_stats['collated']['error'])
validated = local.translate('validated_blocks').format(node_stats['validated']['ok'], node_stats['validated']['error'])
else:
collated = local.translate('collated_blocks').format('collecting data...', 'wait for the next validation round')
validated = local.translate('validated_blocks').format('collecting data...', 'wait for the next validation round')
if ton.using_liteserver():
if 'ls_queries' in node_stats:
ls_queries = local.translate('ls_queries').format(node_stats['ls_queries']['time'], node_stats['ls_queries']['ok'], node_stats['ls_queries']['error'])
else:
local.add_log("Failed to get node statistics", "warning")

dbSize_text = GetColorInt(dbSize, 1000, logic="less", ending=" Gb")
dbUsage_text = GetColorInt(dbUsage, 80, logic="less", ending="%")
Expand Down