Skip to content

Conversation

@yungwine
Copy link
Collaborator

@yungwine yungwine commented Jul 7, 2025

No description provided.

@yungwine yungwine requested a review from Copilot July 7, 2025 11:03
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the retrieval and display of validator and node statistics by improving null checks, caching behavior, and list handling.

  • Added explicit None checks for validator group counts and unified node statistics retrieval via try_function with warning logs.
  • Introduced a no_cache parameter in GetConfig34, reduced its timeout, and refined caching logic.
  • Refactored get_node_statistics indexing to use positive/negative indices correctly and updated how the statistics list is rotated and persisted.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
mytonctrl/mytonctrl.py Strengthened using_validator checks and centralized get_node_statistics call with fallback
mytoncore/mytoncore.py Added no_cache flag to GetConfig34, shortened timeout, and fixed loop placement/index safety in stats
mytoncore/functions.py Updated GetConfig34 usage to bypass cache, refactored node stats list rotation, added save
Comments suppressed due to low confidence (5)

mytonctrl/mytonctrl.py:795

  • [nitpick] It may be helpful to include exception details or context in this log to aid debugging when statistics retrieval fails.
		local.add_log("Failed to get node statistics", "warning")

mytoncore/mytoncore.py:936

  • The timeout was reduced from 60s to 10s; please document the rationale and verify that this shorter timeout handles slower network conditions.
		buff = self.GetFunctionBuffer(bname, timeout=10)

mytoncore/functions.py:320

  • Since GetConfig34 now accepts a no_cache parameter, consider updating its docstring to explain this flag and its effect on caching behavior.
    election_id = ton.GetConfig34(no_cache=True)['startWorkTime']

mytoncore/mytoncore.py:3074

  • [nitpick] Using negative indices is correct but can be less clear. Consider destructuring the last two elements into named variables for readability.
			for k in ['master', 'shard']:

mytonctrl/mytonctrl.py:782

  • If try_function returns an empty object rather than None, the error branch won't trigger; consider checking for expected keys or using exceptions to ensure failures are caught.
	node_stats = local.try_function(ton.get_node_statistics)

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.
@yungwine yungwine merged commit 900cf1a into ton-blockchain:dev Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant