Skip to content

Commit 2c1a238

Browse files
committed
add voting alert
1 parent b7aca1c commit 2c1a238

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

modules/alert_bot.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,17 @@ class Alert:
8484
"stake_returned": Alert(
8585
"info",
8686
"Validator's stake {stake} TON has been returned on address {address}. The reward amount is {reward} TON.",
87-
0
87+
60
8888
),
8989
"stake_not_returned": Alert(
9090
"high",
9191
"Validator's stake has not been returned on address {address}.",
92-
0
92+
60
93+
),
94+
"voting": Alert(
95+
"high",
96+
"Found proposals with hashes `{hashes}` that have significant amount of votes, but current validator didn't vote for them. Please check @tonstatus for more details.",
97+
VALIDATION_PERIOD
9398
),
9499
}
95100

@@ -339,6 +344,19 @@ def check_stake_returned(self):
339344
return
340345
self.send_alert("stake_not_returned", address=res["walletAddr"])
341346

347+
def check_voting(self):
348+
if not self.ton.using_validator():
349+
return
350+
validator_index = self.ton.GetValidatorIndex()
351+
if validator_index == -1:
352+
return
353+
need_to_vote = []
354+
offers = self.ton.GetOffers()
355+
for offer in offers:
356+
if not offer['isPassed'] and offer['approvedPercent'] >= 50 and validator_index not in offer['votedValidators']:
357+
need_to_vote.append(offer['hash'])
358+
if need_to_vote:
359+
self.send_alert("voting", hashes=' '.join(need_to_vote))
342360

343361
def check_status(self):
344362
if not self.ton.using_alert_bot():
@@ -356,6 +374,7 @@ def check_status(self):
356374
self.local.try_function(self.check_adnl_connection_failed)
357375
self.local.try_function(self.check_stake_sent)
358376
self.local.try_function(self.check_stake_returned)
377+
self.local.try_function(self.check_voting)
359378

360379
def add_console_commands(self, console):
361380
console.AddItem("enable_alert", self.enable_alert, self.local.translate("enable_alert_cmd"))

0 commit comments

Comments
 (0)