Skip to content

Commit c3ec6a0

Browse files
committed
Visual changes and bugfix
1 parent 483f86a commit c3ec6a0

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

modules/validator.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,39 @@ def find_myself(self, validators: list) -> dict:
4242

4343
def check_efficiency(self, args):
4444
self.local.add_log("start GetValidatorEfficiency function", "debug")
45-
validators = self.ton.GetValidatorsList(past=True)
46-
validator = self.find_myself(validators)
45+
previous_validators = self.ton.GetValidatorsList(past=True)
46+
validators = self.ton.GetValidatorsList()
47+
validator = self.find_myself(previous_validators)
4748
config32 = self.ton.GetConfig32()
49+
config34 = self.ton.GetConfig34()
50+
color_print("{cyan}===[ Validator efficiency ]==={endc}")
4851
if validator:
49-
efficiency = GetColorInt(validator["efficiency"], 90, logic="more", ending=" %")
50-
expected = validator['blocks_expected']
51-
created = validator['blocks_created']
52-
print('#' * 30)
53-
print(
54-
f"Previous round efficiency: {efficiency} ({created} blocks created / {expected} blocks expected) from {timestamp2utcdatetime(config32['startWorkTime'])} to {timestamp2utcdatetime(config32['endWorkTime'])}")
55-
print('#' * 30)
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}}")
5660
else:
5761
print("Couldn't find this validator in the past round")
58-
validators = self.ton.GetValidatorsList()
5962
validator = self.find_myself(validators)
60-
config34 = self.ton.GetConfig34()
6163
if validator:
62-
efficiency = GetColorInt(validator["efficiency"], 90, logic="more", ending=" %")
63-
expected = validator['blocks_expected']
64-
created = validator['blocks_created']
65-
print('#' * 30)
66-
print(
67-
f"Current round efficiency: {efficiency} ({created} blocks created / {expected} blocks expected) from {timestamp2utcdatetime(config34['startWorkTime'])} to {timestamp2utcdatetime(int(get_timestamp()))}")
68-
print('#' * 30)
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.")
73+
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}}")
6976
else:
7077
print("Couldn't find this validator in the current round")
71-
7278
# end define
7379

7480
def add_console_commands(self, console):

mytoncore/mytoncore.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ def GetConfig32(self):
913913
#end if
914914

915915
self.local.add_log("start GetConfig32 function", "debug")
916-
config32 = dict()
916+
config32 = Dict()
917917
result = self.liteClient.Run("getconfig 32")
918918
config32["totalValidators"] = int(parse(result, "total:", ' '))
919919
config32["mainValidators"] = int(parse(result, "main:", ' '))
@@ -929,7 +929,7 @@ def GetConfig32(self):
929929
validatorWeight = int(parse(line, "weight:", ' '))
930930
except ValueError:
931931
validatorWeight = int(parse(line, "weight:", ')'))
932-
buff = dict()
932+
buff = Dict()
933933
buff["adnlAddr"] = validatorAdnlAddr
934934
buff["pubkey"] = pubkey
935935
buff["weight"] = validatorWeight
@@ -950,7 +950,7 @@ def GetConfig34(self):
950950
#end if
951951

952952
self.local.add_log("start GetConfig34 function", "debug")
953-
config34 = dict()
953+
config34 = Dict()
954954
result = self.liteClient.Run("getconfig 34")
955955
config34["totalValidators"] = int(parse(result, "total:", ' '))
956956
config34["mainValidators"] = int(parse(result, "main:", ' '))
@@ -967,7 +967,7 @@ def GetConfig34(self):
967967
validatorWeight = int(parse(line, "weight:", ' '))
968968
except ValueError:
969969
validatorWeight = int(parse(line, "weight:", ')'))
970-
buff = dict()
970+
buff = Dict()
971971
buff["adnlAddr"] = validatorAdnlAddr
972972
buff["pubkey"] = pubkey
973973
buff["weight"] = validatorWeight
@@ -2618,8 +2618,9 @@ def GetValidatorsList(self, past=False, fast=False):
26182618
start = config.get("startWorkTime")
26192619
end = config.get("endWorkTime") - 60
26202620
save_vl = self.GetSaveVl()
2621-
if start in save_vl:
2622-
return save_vl[start]
2621+
start_str = str(start)
2622+
if start_str in save_vl:
2623+
return save_vl[start_str]
26232624
#end if
26242625

26252626
validatorsLoad = self.GetValidatorsLoad(start, end)

0 commit comments

Comments
 (0)