Skip to content

Commit 999b359

Browse files
committed
allow create collator with existing collators without adding shards to monitor
1 parent 4470d9d commit 999b359

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

modules/collator.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@ def setup_collator(self, args: list):
2222
if not args:
2323
color_print("{red}Bad args. Usage:{endc} setup_collator [--force] [--adnl <ADNL address>] <shard1> <shard2> ...")
2424
return
25-
if self.get_collators() and '--force' not in args:
26-
raise Exception(f'This node already has working collators. Note that it\'s highly not recommended to add new shards for node to monitor. If you are sure you want to add new collator use option `--force`.')
25+
force = '--force' in args
2726
args.remove('--force') if '--force' in args else None
2827
adnl_addr = pop_arg_from_args(args, '--adnl')
2928
shards = args
29+
node_args = get_node_args()
30+
if '--add-shard' not in node_args:
31+
node_args['--add-shard'] = []
32+
shards_need_to_add = [shard for shard in shards if shard not in node_args['--add-shard']]
33+
if '-M' in node_args and shards_need_to_add and not force:
34+
raise Exception(f'This node already has shards to monitor. It\'s highly not recommended to add new shards for node to monitor. If you are sure you want to add new collator use option `--force`.')
35+
3036
if adnl_addr is None:
3137
adnl_addr = self.ton.CreateNewKey()
3238
self.ton.AddAdnlAddrToValidator(adnl_addr)
@@ -36,12 +42,8 @@ def setup_collator(self, args: list):
3642
raise Exception(f'Failed to enable collator: add-collator query failed: {res}')
3743
self.local.add_log(f'Collator added for shards {shards} with ADNL address {adnl_addr}\n'
3844
f'Editing monitoring shards.')
39-
node_args = get_node_args()
4045
if '-M' not in node_args:
4146
set_node_argument(self.local, ['-M'])
42-
if '--add-shard' not in node_args:
43-
node_args['--add-shard'] = []
44-
shards_need_to_add = [shard for shard in shards if shard not in node_args['--add-shard']]
4547
if shards_need_to_add:
4648
set_node_argument(self.local, ['--add-shard', ' '.join(node_args['--add-shard'] + shards_need_to_add)])
4749
commands_text = [f'`add_collator {s} {adnl_addr}`' for s in shards]

0 commit comments

Comments
 (0)