Skip to content

Commit

Permalink
[Chore] Unify interactive queries in tezos-setup
Browse files Browse the repository at this point in the history
Problem: Some interactive queries use step concept,
while others are done through `yes_or_no`. It's useful
to unify them by using steps only for logging
and for the #568 (non-interactive mode) issue.

Solution: Rewrite delete node data query using steps
instead of `yes_or_no`.
  • Loading branch information
krendelhoff2 committed Jul 17, 2023
1 parent 427991a commit 8b6e652
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion docker/package/tezos_setup_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ def get_snapshot_mode_query(modes):
)


delete_node_data_options = {
"no": "Keep the existing data",
"yes": "Remove the data under the tezos node data directory",
}

delele_node_data_query = Step(
id="delete_node_data",
prompt="Delete this data and bootstrap the node again?",
help="It's possible to proceed with bootstrapping the node using\n"
"the existing blockchain data, instead of importing fresh snapshot.",
options=delete_node_data_options,
validator=Validator(enum_range_validator(delete_node_data_options)),
)

snapshot_file_query = Step(
id="snapshot_file",
prompt="Provide the path to the node snapshot file.",
Expand Down Expand Up @@ -239,7 +253,8 @@ def check_blockchain_data(self):
if diff:
print("The Tezos node data directory already has some blockchain data:")
print("\n".join(["- " + os.path.join(node_dir, path) for path in diff]))
if yes_or_no("Delete this data and bootstrap the node again? <y/N> ", "no"):
self.query_step(delele_node_data_query)
if self.config["delete_node_data"] == "yes":
# We first stop the node service, because it's possible that it
# will re-create some of the files while we go on with the wizard
print("Stopping node service")
Expand Down

0 comments on commit 8b6e652

Please sign in to comment.