@@ -186,7 +186,6 @@ def inject_globals(func):
186186#end define
187187
188188
189-
190189def activate_ton_storage_provider (local , ton , args ):
191190 wallet_name = "provider_wallet_001"
192191 wallet = ton .GetLocalWallet (wallet_name )
@@ -304,7 +303,7 @@ def fix_git_config(git_path: str):
304303 subprocess .run (args , stdin = subprocess .PIPE , stdout = subprocess .PIPE , stderr = subprocess .PIPE , timeout = 3 )
305304 else :
306305 raise Exception (f'Failed to check git status: { err } ' )
307-
306+ #end define
308307
309308def check_git (input_args , default_repo , text ):
310309 src_dir = "/usr/src"
@@ -341,7 +340,7 @@ def check_git(input_args, default_repo, text):
341340 need_branch = local_branch
342341 check_branch_exists (need_author , need_repo , need_branch )
343342 return need_author , need_repo , need_branch
344-
343+ #end define
345344
346345def check_branch_exists (author , repo , branch ):
347346 url = f"https://github.com/{ author } /{ repo } .git"
@@ -350,7 +349,7 @@ def check_branch_exists(author, repo, branch):
350349 output = process .stdout .decode ("utf-8" )
351350 if branch not in output :
352351 raise Exception (f"Branch { branch } not found in { url } " )
353-
352+ #end define
354353
355354def Update (local , args ):
356355 repo = "mytonctrl"
@@ -399,7 +398,7 @@ def Upgrade(ton, args):
399398 else :
400399 text = "Upgrade - {red}Error{endc}"
401400 color_print (text )
402-
401+ #end define
403402
404403def rollback_to_mtc1 (local , ton , args ):
405404 color_print ("{red}Warning: this is dangerous, please make sure you've backed up mytoncore's db.{endc}" )
@@ -418,7 +417,7 @@ def rollback_to_mtc1(local, ton, args):
418417 run_args = ["bash" , rollback_script_path ]
419418 run_as_root (run_args )
420419 local .exit ()
421-
420+ #end define
422421
423422def cleanup_validator_db (ton , args ):
424423 cleanup_script_path = pkg_resources .resource_filename ('mytonctrl' , 'scripts/cleanup.sh' )
@@ -470,6 +469,7 @@ def check_disk_usage(local, ton):
470469
471470def warnings (local , ton ):
472471 check_disk_usage (local , ton )
472+ #end define
473473
474474def CheckTonUpdate (local ):
475475 git_path = "/usr/src/ton"
@@ -513,49 +513,67 @@ def PrintStatus(local, ton, args):
513513 opt = None
514514 if len (args ) == 1 :
515515 opt = args [0 ]
516- adnlAddr = ton .GetAdnlAddr ()
517- rootWorkchainEnabledTime_int = ton .GetRootWorkchainEnabledTime ()
518- config34 = ton .GetConfig34 ()
519- config36 = ton .GetConfig36 ()
520- totalValidators = config34 ["totalValidators" ]
516+
517+ # Local status
518+ validator_status = ton .GetValidatorStatus ()
519+ vconfig = self .GetValidatorConfig ()
520+ adnl_addr = ton .GetAdnlAddr ()
521+ validator_index = None
521522 onlineValidators = None
522- validatorEfficiency = None
523- if opt != "fast" :
524- onlineValidators = ton .GetOnlineValidators ()
525- validatorEfficiency = ton .GetValidatorEfficiency ()
526- if onlineValidators :
527- onlineValidators = len (onlineValidators )
528- oldStartWorkTime = config36 .get ("startWorkTime" )
529- if oldStartWorkTime is None :
530- oldStartWorkTime = config34 .get ("startWorkTime" )
531- shardsNumber = ton .GetShardsNumber ()
532- validatorStatus = ton .GetValidatorStatus ()
533- config15 = ton .GetConfig15 ()
534- config17 = ton .GetConfig17 ()
535- fullConfigAddr = ton .GetFullConfigAddr ()
536- fullElectorAddr = ton .GetFullElectorAddr ()
537- startWorkTime = ton .GetActiveElectionId (fullElectorAddr )
538- validatorIndex = ton .GetValidatorIndex ()
539- validatorWallet = ton .GetValidatorWallet ()
540- dbSize = ton .GetDbSize ()
541- dbUsage = ton .GetDbUsage ()
542- memoryInfo = GetMemoryInfo ()
543- swapInfo = GetSwapInfo ()
544- offersNumber = ton .GetOffersNumber ()
545- complaintsNumber = ton .GetComplaintsNumber ()
523+ validator_efficiency = None
524+ validator_wallet = ton .GetValidatorWallet ()
525+ validator_account = Dict ()
526+ db_size = ton .GetDbSize ()
527+ db_usage = ton .GetDbUsage ()
528+ memory_info = GetMemoryInfo ()
529+ swap_info = GetSwapInfo ()
546530 statistics = ton .GetSettings ("statistics" )
547- tpsAvg = ton .GetStatistics ("tpsAvg" , statistics )
548- netLoadAvg = ton .GetStatistics ("netLoadAvg" , statistics )
549- disksLoadAvg = ton .GetStatistics ("disksLoadAvg" , statistics )
550- disksLoadPercentAvg = ton .GetStatistics ("disksLoadPercentAvg" , statistics )
551- if validatorWallet is not None :
552- validatorAccount = ton .GetAccount (validatorWallet .addrB64 )
553- else :
554- validatorAccount = None
555- PrintTonStatus (local , startWorkTime , totalValidators , onlineValidators , shardsNumber , offersNumber , complaintsNumber , tpsAvg )
556- PrintLocalStatus (local , adnlAddr , validatorIndex , validatorEfficiency , validatorWallet , validatorAccount , validatorStatus , dbSize , dbUsage , memoryInfo , swapInfo , netLoadAvg , disksLoadAvg , disksLoadPercentAvg )
557- PrintTonConfig (local , fullConfigAddr , fullElectorAddr , config15 , config17 )
558- PrintTimes (local , rootWorkchainEnabledTime_int , startWorkTime , oldStartWorkTime , config15 )
531+ net_load_avg = ton .GetStatistics ("netLoadAvg" , statistics )
532+ disks_load_avg = ton .GetStatistics ("disksLoadAvg" , statistics )
533+ disks_load_percent_avg = ton .GetStatistics ("disksLoadPercentAvg" , statistics )
534+
535+ #is_validator = len(vconfig.validators) > 0
536+ all_status = validator_status .is_working == True and validator_status .out_of_sync < 20
537+ if all_status :
538+ rootWorkchainEnabledTime_int = ton .GetRootWorkchainEnabledTime ()
539+ config34 = ton .GetConfig34 ()
540+ config36 = ton .GetConfig36 ()
541+ totalValidators = config34 ["totalValidators" ]
542+
543+ if opt != "fast" :
544+ onlineValidators = ton .GetOnlineValidators ()
545+ validator_efficiency = ton .GetValidatorEfficiency ()
546+ if onlineValidators :
547+ onlineValidators = len (onlineValidators )
548+
549+ oldStartWorkTime = config36 .get ("startWorkTime" )
550+ if oldStartWorkTime is None :
551+ oldStartWorkTime = config34 .get ("startWorkTime" )
552+ shardsNumber = ton .GetShardsNumber ()
553+
554+ config15 = ton .GetConfig15 ()
555+ config17 = ton .GetConfig17 ()
556+ fullConfigAddr = ton .GetFullConfigAddr ()
557+ fullElectorAddr = ton .GetFullElectorAddr ()
558+ startWorkTime = ton .GetActiveElectionId (fullElectorAddr )
559+ validator_index = ton .GetValidatorIndex ()
560+
561+ offersNumber = ton .GetOffersNumber ()
562+ complaintsNumber = ton .GetComplaintsNumber ()
563+
564+ tpsAvg = ton .GetStatistics ("tpsAvg" , statistics )
565+
566+ if validator_wallet is not None :
567+ validator_account = ton .GetAccount (validator_wallet .addrB64 )
568+ #end if
569+
570+ if all_status :
571+ PrintTonStatus (local , startWorkTime , totalValidators , onlineValidators , shardsNumber , offersNumber , complaintsNumber , tpsAvg )
572+ PrintLocalStatus (local , adnl_addr , validator_index , validator_efficiency , validator_wallet , validator_account , validator_status ,
573+ db_size , db_usage , memory_info , swap_info , net_load_avg , disks_load_avg , disks_load_percent_avg )
574+ if all_status :
575+ PrintTonConfig (local , fullConfigAddr , fullElectorAddr , config15 , config17 )
576+ PrintTimes (local , rootWorkchainEnabledTime_int , startWorkTime , oldStartWorkTime , config15 )
559577#end define
560578
561579def PrintTonStatus (local , startWorkTime , totalValidators , onlineValidators , shardsNumber , offersNumber , complaintsNumber , tpsAvg ):
@@ -1371,7 +1389,7 @@ def enable_mode(local, ton, args):
13711389 ton .enable_mode (name )
13721390 color_print ("enable_mode - {green}OK{endc}" )
13731391 local .exit ()
1374-
1392+ #end define
13751393
13761394def disable_mode (local , ton , args ):
13771395 try :
@@ -1382,7 +1400,7 @@ def disable_mode(local, ton, args):
13821400 ton .disable_mode (name )
13831401 color_print ("disable_mode - {green}OK{endc}" )
13841402 local .exit ()
1385-
1403+ #end define
13861404
13871405def Xrestart (inputArgs ):
13881406 if len (inputArgs ) < 2 :
@@ -1436,6 +1454,7 @@ def GetPoolData(ton, args):
14361454 pool_addr = pool .addrB64
14371455 pool_data = ton .GetPoolData (pool_addr )
14381456 print (json .dumps (pool_data , indent = 4 ))
1457+ #end define
14391458
14401459
14411460### Start of the program
0 commit comments