Skip to content

Commit 3cd99d0

Browse files
authored
Merge pull request #348 from yungwine/efficiency
Efficiency
2 parents d5a8869 + d6cf9df commit 3cd99d0

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

modules/validator.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,30 +49,36 @@ def check_efficiency(self, args):
4949
config34 = self.ton.GetConfig34()
5050
color_print("{cyan}===[ Validator efficiency ]==={endc}")
5151
if validator:
52-
efficiency = 100 if validator.efficiency > 100 else validator.efficiency
53-
color_efficiency = GetColorInt(efficiency, 90, logic="more", ending="%")
54-
created = validator.blocks_created
55-
expected = validator.blocks_expected
56-
start_time = timestamp2utcdatetime(config32.startWorkTime)
57-
end_time = timestamp2utcdatetime(config32.endWorkTime)
58-
color_print(f"Previous round efficiency: {color_efficiency} {{yellow}}({created} blocks created / {expected} blocks expected){{endc}}")
59-
color_print(f"Previous round time: {{yellow}}from {start_time} to {end_time}{{endc}}")
52+
if validator.get('efficiency') is None:
53+
print('Failed to get efficiency for the past round')
54+
else:
55+
efficiency = 100 if validator.efficiency > 100 else validator.efficiency
56+
color_efficiency = GetColorInt(efficiency, 90, logic="more", ending="%")
57+
created = validator.blocks_created
58+
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}}")
6063
else:
6164
print("Couldn't find this validator in the past round")
6265
validator = self.find_myself(validators)
6366
if validator:
64-
efficiency = 100 if validator.efficiency > 100 else validator.efficiency
65-
color_efficiency = GetColorInt(efficiency, 90, logic="more", ending="%")
66-
created = validator.blocks_created
67-
expected = validator.blocks_expected
68-
start_time = timestamp2utcdatetime(config34.startWorkTime)
69-
end_time = timestamp2utcdatetime(int(get_timestamp()))
70-
if validator.is_masterchain == False and efficiency < 90:
71-
print("Your validator index is greater than 100.")
72-
print("Efficiency before the validation round is complete may be inaccurate and not displayed.")
67+
if validator.get('efficiency') is None:
68+
print('Failed to get efficiency for the current round')
7369
else:
74-
color_print(f"Current round efficiency: {color_efficiency} {{yellow}}({created} blocks created / {expected} blocks expected){{endc}}")
75-
color_print(f"Current round time: {{green}}from {start_time} to {end_time}{{endc}}")
70+
efficiency = 100 if validator.efficiency > 100 else validator.efficiency
71+
color_efficiency = GetColorInt(efficiency, 90, logic="more", ending="%")
72+
created = validator.blocks_created
73+
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}}")
7682
else:
7783
print("Couldn't find this validator in the current round")
7884
# end define

mytoncore/mytoncore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2650,7 +2650,7 @@ def GetValidatorsList(self, past=False, fast=False):
26502650
self.SetFunctionBuffer(bname, validators)
26512651
if past:
26522652
save_vl = self.GetSaveVl()
2653-
save_vl[start] = validators
2653+
save_vl[str(start)] = validators
26542654
return validators
26552655
#end define
26562656

0 commit comments

Comments
 (0)