@@ -80,6 +80,47 @@ def setup_collator(self, args: list):
8080 + '\n ' .join (commands_text ))
8181 color_print ("setup_collator - {green}OK{endc}" )
8282
83+ def stop_collator (self , args : list ):
84+ if not args :
85+ text = f"{{red}}WARNING: This action will stop and delete all local collation broadcasts from this node for all shards.{{endc}}\n "
86+ color_print (text )
87+ if input ("Continue anyway? [Y/n]\n " ).strip ().lower () not in ('y' , '' ):
88+ print ('aborted.' )
89+ return
90+ collators = self .get_collators ()
91+ if not collators :
92+ print ("No collators found" )
93+ return
94+ errors = []
95+ for c in collators :
96+ adnl_hex = b642hex (c ['adnl_id' ]).upper ()
97+ workchain = int (c ['shard' ]['workchain' ])
98+ shard_int = int (c ['shard' ]['shard' ])
99+ res = self .ton .validatorConsole .Run (f"del-collator { adnl_hex } { workchain } { shard_int } " )
100+ if 'success' not in res .lower ():
101+ errors .append (res .strip ())
102+ if errors :
103+ raise Exception (f"Failed to delete some collators: { '; ' .join (errors )} " )
104+ color_print ("stop_collator - {green}OK{endc}" )
105+ return
106+
107+ if len (args ) == 2 :
108+ adnl_addr , shard_str = args
109+ if ':' not in shard_str :
110+ color_print ("{red}Bad args. Usage:{endc} stop_collator <adnl_id> <workchain>:<shard_hex>" )
111+ return
112+ shard_id = hex_shard_to_int (shard_str )
113+ workchain = int (shard_id ['workchain' ])
114+ shard_int = int (shard_id ['shard' ])
115+ else :
116+ color_print ("{red}Bad args. Usage:{endc} stop_collator <adnl_id> <workchain>:<shard_hex>" )
117+ return
118+
119+ res = self .ton .validatorConsole .Run (f"del-collator { adnl_addr } { workchain } { shard_int } " )
120+ if 'successfully removed collator' not in res .lower ():
121+ raise Exception (f'Failed to disable collator: del-collator query failed: { res } ' )
122+ color_print ("stop_collator - {green}OK{endc}" )
123+
83124 def get_collators (self ):
84125 return self .ton .GetValidatorConfig ()['collators' ]
85126
@@ -139,7 +180,7 @@ def check_enable(cls, ton: "MyTonCore"):
139180 def check_disable (self ):
140181 if not self .get_collators ():
141182 return
142- text = f"{{red}}WARNING: This node has active collator working and probably synchronizes not the whole blockchain, thus it may not work as expected in other node modes. Make sure you know what you're doing.{{endc}}\n "
183+ text = f"{{red}}WARNING: This node probably has active collator working and synchronizes not the whole blockchain, thus it may not work as expected in other node modes. Make sure you know what you're doing.{{endc}}\n "
143184 color_print (text )
144185 if input ("Continue anyway? [Y/n]\n " ).strip ().lower () not in ('y' , '' ):
145186 print ('aborted.' )
@@ -152,3 +193,4 @@ def add_console_commands(self, console):
152193 console .AddItem ("delete_validator_from_collation_wl" , self .delete_validator_from_collation_wl , self .local .translate ("delete_validator_from_collation_wl_cmd" ))
153194 console .AddItem ("disable_collation_wl" , self .disable_collation_validator_wl , self .local .translate ("disable_collation_validator_wl_cmd" ))
154195 console .AddItem ("print_collation_whitelist" , self .print_collation_validators_whitelist , self .local .translate ("print_collation_validators_whitelist_cmd" ))
196+ console .AddItem ("stop_collator" , self .stop_collator , self .local .translate ("stop_collator_cmd" ))
0 commit comments