Skip to content

Commit f1ea228

Browse files
committed
add initial sync alert
do not send some alerts if initial sync
1 parent c4ac040 commit f1ea228

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

modules/alert_bot.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ def init_alerts():
116116
"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.",
117117
VALIDATION_PERIOD
118118
),
119+
"initial_sync_completed": Alert(
120+
"info",
121+
"Initial sync has been completed (info alert with no sound)",
122+
"Node initial sync has been completed",
123+
0
124+
)
119125
}
120126

121127

@@ -134,6 +140,7 @@ def __init__(self, ton, local, *args, **kwargs):
134140
self.token = None
135141
self.chat_id = None
136142
self.last_db_check = 0
143+
self.initial_sync = None
137144

138145
def send_message(self, text: str, silent: bool = False, disable_web_page_preview: bool = False):
139146
if self.token is None:
@@ -198,6 +205,7 @@ def init(self):
198205
self.wallet = self.ton.GetValidatorWallet().addrB64
199206
self.ip = self.ton.get_node_ip()
200207
self.set_global_vars()
208+
self.initial_sync = self.ton.in_initial_sync()
201209
init_alerts()
202210
self.inited = True
203211

@@ -323,12 +331,12 @@ def check_efficiency(self):
323331

324332
def check_validator_working(self):
325333
validator_status = self.ton.GetValidatorStatus()
326-
if not validator_status.is_working:
334+
if not self.initial_sync and not validator_status.is_working:
327335
self.send_alert("service_down")
328336

329337
def check_sync(self):
330338
validator_status = self.ton.GetValidatorStatus()
331-
if validator_status.is_working and validator_status.out_of_sync >= 20:
339+
if not self.initial_sync and validator_status.is_working and validator_status.out_of_sync >= 20:
332340
self.send_alert("out_of_sync", sync=validator_status.out_of_sync)
333341

334342
def check_zero_blocks_created(self):
@@ -423,6 +431,13 @@ def check_voting(self):
423431
if need_to_vote:
424432
self.send_alert("voting", hashes=' '.join(need_to_vote))
425433

434+
def check_initial_sync(self):
435+
if not self.initial_sync:
436+
return
437+
if not self.ton.in_initial_sync():
438+
self.initial_sync = False
439+
self.send_alert("initial_sync_completed")
440+
426441
def check_status(self):
427442
if not self.ton.using_alert_bot():
428443
return
@@ -441,6 +456,7 @@ def check_status(self):
441456
self.local.try_function(self.check_stake_sent)
442457
self.local.try_function(self.check_stake_returned)
443458
self.local.try_function(self.check_voting)
459+
self.local.try_function(self.check_initial_sync)
444460

445461
def add_console_commands(self, console):
446462
console.AddItem("enable_alert", self.enable_alert, self.local.translate("enable_alert_cmd"))

0 commit comments

Comments
 (0)