|
| 1 | +import time |
| 2 | + |
1 | 3 | from mypylib.mypylib import color_print, get_timestamp |
2 | 4 | from modules.module import MtcModule |
3 | 5 | from mytonctrl.utils import timestamp2utcdatetime, GetColorInt |
@@ -48,37 +50,40 @@ def check_efficiency(self, args): |
48 | 50 | config32 = self.ton.GetConfig32() |
49 | 51 | config34 = self.ton.GetConfig34() |
50 | 52 | color_print("{cyan}===[ Validator efficiency ]==={endc}") |
| 53 | + start_time = timestamp2utcdatetime(config32.startWorkTime) |
| 54 | + end_time = timestamp2utcdatetime(config32.endWorkTime) |
| 55 | + color_print(f"Previous round time: {{yellow}}from {start_time} to {end_time}{{endc}}") |
51 | 56 | if validator: |
52 | | - if validator.get('efficiency') is None: |
53 | | - print('Failed to get efficiency for the past round') |
| 57 | + if validator.is_masterchain == False: |
| 58 | + print("Validator index is greater than 100 in the previous round - no efficiency data.") |
| 59 | + elif validator.get('efficiency') is None: |
| 60 | + print('Failed to get efficiency for the previous round') |
54 | 61 | else: |
55 | 62 | efficiency = 100 if validator.efficiency > 100 else validator.efficiency |
56 | 63 | color_efficiency = GetColorInt(efficiency, 90, logic="more", ending="%") |
57 | 64 | created = validator.blocks_created |
58 | 65 | expected = validator.blocks_expected |
59 | | - start_time = timestamp2utcdatetime(config32.startWorkTime) |
60 | | - end_time = timestamp2utcdatetime(config32.endWorkTime) |
61 | | - color_print(f"Previous round efficiency: {color_efficiency} {{yellow}}({created} blocks created / {expected} blocks expected){{endc}}") |
62 | | - color_print(f"Previous round time: {{yellow}}from {start_time} to {end_time}{{endc}}") |
| 66 | + color_print(f"Previous round efficiency: {color_efficiency} {{yellow}}({created} blocks created / {round(expected, 1)} blocks expected){{endc}}") |
63 | 67 | else: |
64 | | - print("Couldn't find this validator in the past round") |
| 68 | + print("Couldn't find this validator in the previous round") |
65 | 69 | validator = self.find_myself(validators) |
| 70 | + start_time = timestamp2utcdatetime(config34.startWorkTime) |
| 71 | + end_time = timestamp2utcdatetime(int(get_timestamp())) |
| 72 | + color_print(f"Current round time: {{green}}from {start_time} to {end_time}{{endc}}") |
66 | 73 | if validator: |
67 | | - if validator.get('efficiency') is None: |
| 74 | + if validator.is_masterchain == False: |
| 75 | + print("Validator index is greater than 100 in the current round - no efficiency data.") |
| 76 | + elif (time.time() - config34.startWorkTime) / (config34.endWorkTime - config34.startWorkTime) < 0.8: |
| 77 | + print("The validation round has started recently, there is not enough data yet. " |
| 78 | + "The efficiency evaluation will become more accurate towards the end of the round.") |
| 79 | + elif validator.get('efficiency') is None: |
68 | 80 | print('Failed to get efficiency for the current round') |
69 | 81 | else: |
70 | 82 | efficiency = 100 if validator.efficiency > 100 else validator.efficiency |
71 | 83 | color_efficiency = GetColorInt(efficiency, 90, logic="more", ending="%") |
72 | 84 | created = validator.blocks_created |
73 | 85 | expected = validator.blocks_expected |
74 | | - start_time = timestamp2utcdatetime(config34.startWorkTime) |
75 | | - end_time = timestamp2utcdatetime(int(get_timestamp())) |
76 | | - if not validator.is_masterchain and efficiency < 90: |
77 | | - print("Your validator index is greater than 100.") |
78 | | - print("Efficiency while the validation round is active may be inaccurate and not displayed.") |
79 | | - else: |
80 | | - color_print(f"Current round efficiency: {color_efficiency} {{yellow}}({created} blocks created / {expected} blocks expected){{endc}}") |
81 | | - color_print(f"Current round time: {{green}}from {start_time} to {end_time}{{endc}}") |
| 86 | + color_print(f"Current round efficiency: {color_efficiency} {{yellow}}({created} blocks created / {round(expected, 1)} blocks expected){{endc}}") |
82 | 87 | else: |
83 | 88 | print("Couldn't find this validator in the current round") |
84 | 89 | # end define |
|
0 commit comments