Skip to content

Commit 056571a

Browse files
committed
Set catchup True when --archive
1 parent ee38092 commit 056571a

File tree

7 files changed

+15
-27
lines changed

7 files changed

+15
-27
lines changed

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ Options:
560560

561561
- `--archive` - Run sync node in an archive node (disable block rotation)
562562
- `--historic-state` - Enable historic state (works only in pair with --archive flag)
563-
- `--catchup` - Add a flag to start sync node in catchup mode
564563

565564
#### Sync node update
566565

node_cli/cli/sync_node.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ def sync_node():
5353
help=TEXTS['init']['archive'],
5454
is_flag=True
5555
)
56-
@click.option(
57-
'--catchup',
58-
help=TEXTS['init']['catchup'],
59-
is_flag=True
60-
)
6156
@click.option(
6257
'--historic-state',
6358
help=TEXTS['init']['historic_state'],
@@ -71,13 +66,13 @@ def sync_node():
7166
help='Ip of the node from to download snapshot from'
7267
)
7368
@streamed_cmd
74-
def _init_sync(env_file, archive, catchup, historic_state, snapshot_from: Optional[str]):
69+
def _init_sync(env_file, archive, historic_state, snapshot_from: Optional[str]):
7570
if historic_state and not archive:
7671
error_exit(
7772
'--historic-state can be used only is combination with --archive',
7873
exit_code=CLIExitCodes.FAILURE
7974
)
80-
init_sync(env_file, archive, catchup, historic_state, snapshot_from)
75+
init_sync(env_file, archive, historic_state, snapshot_from)
8176

8277

8378
@sync_node.command('update', help='Update sync node from .env file')
@@ -106,11 +101,6 @@ def _update_sync(env_file, unsafe_ok):
106101
help=TEXTS['init']['archive'],
107102
is_flag=True
108103
)
109-
@click.option(
110-
'--catchup',
111-
help=TEXTS['init']['catchup'],
112-
is_flag=True
113-
)
114104
@click.option(
115105
'--historic-state',
116106
help=TEXTS['init']['historic_state'],
@@ -126,13 +116,11 @@ def _update_sync(env_file, unsafe_ok):
126116
@streamed_cmd
127117
def _repair_sync(
128118
archive: str,
129-
catchup: str,
130119
historic_state: str,
131120
snapshot_from: Optional[str] = None
132121
) -> None:
133122
repair_sync(
134123
archive=archive,
135-
catchup=catchup,
136124
historic_state=historic_state,
137125
snapshot_from=snapshot_from
138126
)

node_cli/core/node.py

-4
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ def restore(backup_path, env_filepath, no_snapshot=False, config_only=False):
186186
def init_sync(
187187
env_filepath: str,
188188
archive: bool,
189-
catchup: bool,
190189
historic_state: bool,
191190
snapshot_from: str
192191
) -> None:
@@ -198,7 +197,6 @@ def init_sync(
198197
env_filepath,
199198
env,
200199
archive,
201-
catchup,
202200
historic_state,
203201
snapshot_from
204202
)
@@ -239,7 +237,6 @@ def update_sync(env_filepath: str, unsafe_ok: bool = False) -> None:
239237
@check_user
240238
def repair_sync(
241239
archive: bool,
242-
catchup: bool,
243240
historic_state: bool,
244241
snapshot_from: str
245242
) -> None:
@@ -249,7 +246,6 @@ def repair_sync(
249246
repair_sync_op(
250247
schain_name=schain_name,
251248
archive=archive,
252-
catchup=catchup,
253249
historic_state=historic_state,
254250
snapshot_from=snapshot_from
255251
)

node_cli/operations/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ def init_sync(
187187
env_filepath: str,
188188
env: dict,
189189
archive: bool,
190-
catchup: bool,
191190
historic_state: bool,
192191
snapshot_from: Optional[str]
193192
) -> bool:
@@ -208,7 +207,8 @@ def init_sync(
208207

209208
node_options = NodeOptions()
210209
node_options.archive = archive
211-
node_options.catchup = catchup
210+
if archive:
211+
node_options.catchup = True
212212
node_options.historic_state = historic_state
213213

214214
ensure_filestorage_mapping()
@@ -352,7 +352,6 @@ def restore(env, backup_path, config_only=False):
352352
def repair_sync(
353353
schain_name: str,
354354
archive: bool,
355-
catchup: bool,
356355
historic_state: bool,
357356
snapshot_from: Optional[str]
358357
) -> None:
@@ -365,7 +364,8 @@ def repair_sync(
365364
logger.info('Updating node options')
366365
node_options = NodeOptions()
367366
node_options.archive = archive
368-
node_options.catchup = catchup
367+
if archive:
368+
node_options.catchup = True
369369
node_options.historic_state = historic_state
370370

371371
logger.info('Updating cli status')

tests/cli/sync_node_test.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,16 @@ def test_init_sync(mocked_g_config):
4444
'node_cli.utils.decorators.is_node_inited', return_value=False
4545
):
4646
result = run_command(_init_sync, ['./tests/test-env'])
47+
48+
node_options = NodeOptions()
49+
assert not node_options.archive
50+
assert not node_options.catchup
51+
assert not node_options.historic_state
52+
4753
assert result.exit_code == 0
4854

4955

50-
def test_init_sync_archive_catchup(mocked_g_config, clean_node_options):
56+
def test_init_sync_archive(mocked_g_config, clean_node_options):
5157
pathlib.Path(NODE_DATA_PATH).mkdir(parents=True, exist_ok=True)
5258
# with mock.patch('subprocess.run', new=subprocess_run_mock), \
5359
with mock.patch('node_cli.core.node.is_base_containers_alive', return_value=True), mock.patch(
@@ -70,7 +76,7 @@ def test_init_sync_archive_catchup(mocked_g_config, clean_node_options):
7076
'node_cli.utils.decorators.is_node_inited', return_value=False
7177
):
7278
result = run_command(
73-
_init_sync, ['./tests/test-env', '--archive', '--catchup', '--historic-state']
79+
_init_sync, ['./tests/test-env', '--archive', '--historic-state']
7480
)
7581
node_options = NodeOptions()
7682

tests/core/core_node_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,4 @@ def test_repair_sync(tmp_sync_datadir, mocked_g_config, resource_file):
191191
with mock.patch('node_cli.core.schains.rm_btrfs_subvolume'), \
192192
mock.patch('node_cli.utils.docker_utils.stop_container'), \
193193
mock.patch('node_cli.utils.docker_utils.start_container'):
194-
repair_sync(archive=True, catchup=True, historic_state=True, snapshot_from='127.0.0.1')
194+
repair_sync(archive=True, historic_state=True, snapshot_from='127.0.0.1')

text.yml

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ sync_node:
6565
help: Initialize sync SKALE node
6666
archive: Run sync node in an archive node (disable block rotation)
6767
historic_state: Enable historic state (works only in pair with --archive flag)
68-
catchup: Add a flag to start sync node in catchup mode
6968

7069
lvmpy:
7170
help: Lvmpy commands

0 commit comments

Comments
 (0)