Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confirmation_height_clear cli account param #3836

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions nano/node/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
}
else
{
std::cerr << "wallet_add command requires one <wallet> option and one <key> option and optionally one <password> option\n";
std::cerr << "account_create command requires one <wallet> option and optionally one <password> option\n";
ec = nano::error_cli::invalid_arguments;
}
}
Expand Down Expand Up @@ -579,10 +579,9 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
nano::inactive_node node (data_path, node_flags);
if (!node.node->init_error ())
{
auto account_it = vm.find ("account");
if (account_it != vm.cend ())
if (vm.count ("account") == 1)
{
auto account_str = account_it->second.as<std::string> ();
auto account_str = vm["account"].as<std::string> ();
nano::account account;
if (!account.decode_account (account_str))
{
Expand All @@ -609,17 +608,22 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
ec = nano::error_cli::generic;
}
}
else if (account_str == "all")
{
auto transaction (node.node->store.tx_begin_write ());
reset_confirmation_heights (transaction, node.node->network_params.ledger, node.node->store);
std::cout << "Confirmation heights of all accounts (except genesis which is set to 1) are set to 0" << std::endl;
}
else
{
std::cerr << "Invalid account id\n";
std::cerr << "Specify either valid account id or 'all'\n";
ec = nano::error_cli::invalid_arguments;
}
}
else
{
auto transaction (node.node->store.tx_begin_write ());
reset_confirmation_heights (transaction, node.node->network_params.ledger, node.node->store);
std::cout << "Confirmation heights of all accounts (except genesis which is set to 1) are set to 0" << std::endl;
std::cerr << "confirmation_height_clear command requires one <account> option\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could also say: "or 'any' to clear all accounts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved this and also the help message to the --confirmation_height_clear option.

ec = nano::error_cli::invalid_arguments;
}
}
else
Expand Down