confirmation_height_clear cli account param (#3836)
* confirmation_height_clear cli account param * Add back missing password option * Improve the error/help messages to the required account option - Improve the error message to say the account can be 'all' - Improve the confirmation_height_clear help message to inform the value 'all' can be passed to clear all accounts Co-authored-by: Thiago Silva <thiago@nano.org>
This commit is contained in:
		
					parent
					
						
							
								4d65b8c32a
							
						
					
				
			
			
				commit
				
					
						bee7044d3f
					
				
			
		
					 1 changed files with 13 additions and 9 deletions
				
			
		| 
						 | 
					@ -57,7 +57,7 @@ void nano::add_node_options (boost::program_options::options_description & descr
 | 
				
			||||||
	("online_weight_clear", "Clear online weight history records")
 | 
						("online_weight_clear", "Clear online weight history records")
 | 
				
			||||||
	("peer_clear", "Clear online peers database dump")
 | 
						("peer_clear", "Clear online peers database dump")
 | 
				
			||||||
	("unchecked_clear", "Clear unchecked blocks")
 | 
						("unchecked_clear", "Clear unchecked blocks")
 | 
				
			||||||
	("confirmation_height_clear", "Clear confirmation height")
 | 
						("confirmation_height_clear", "Clear confirmation height. Requires an <account> option that can be 'all' to clear all accounts")
 | 
				
			||||||
	("final_vote_clear", "Clear final votes")
 | 
						("final_vote_clear", "Clear final votes")
 | 
				
			||||||
	("rebuild_database", "Rebuild LMDB database with vacuum for best compaction")
 | 
						("rebuild_database", "Rebuild LMDB database with vacuum for best compaction")
 | 
				
			||||||
	("migrate_database_lmdb_to_rocksdb", "Migrates LMDB database to RocksDB")
 | 
						("migrate_database_lmdb_to_rocksdb", "Migrates LMDB database to RocksDB")
 | 
				
			||||||
| 
						 | 
					@ -321,7 +321,7 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							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;
 | 
								ec = nano::error_cli::invalid_arguments;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -579,10 +579,9 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
 | 
				
			||||||
		nano::inactive_node node (data_path, node_flags);
 | 
							nano::inactive_node node (data_path, node_flags);
 | 
				
			||||||
		if (!node.node->init_error ())
 | 
							if (!node.node->init_error ())
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			auto account_it = vm.find ("account");
 | 
								if (vm.count ("account") == 1)
 | 
				
			||||||
			if (account_it != vm.cend ())
 | 
					 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				auto account_str = account_it->second.as<std::string> ();
 | 
									auto account_str = vm["account"].as<std::string> ();
 | 
				
			||||||
				nano::account account;
 | 
									nano::account account;
 | 
				
			||||||
				if (!account.decode_account (account_str))
 | 
									if (!account.decode_account (account_str))
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
| 
						 | 
					@ -609,17 +608,22 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
 | 
				
			||||||
						ec = nano::error_cli::generic;
 | 
											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
 | 
									else
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					std::cerr << "Invalid account id\n";
 | 
										std::cerr << "Specify either valid account id or 'all'\n";
 | 
				
			||||||
					ec = nano::error_cli::invalid_arguments;
 | 
										ec = nano::error_cli::invalid_arguments;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				auto transaction (node.node->store.tx_begin_write ());
 | 
									std::cerr << "confirmation_height_clear command requires one <account> option that may contain an account or the value 'all'\n";
 | 
				
			||||||
				reset_confirmation_heights (transaction, node.node->network_params.ledger, node.node->store);
 | 
									ec = nano::error_cli::invalid_arguments;
 | 
				
			||||||
				std::cout << "Confirmation heights of all accounts (except genesis which is set to 1) are set to 0" << std::endl;
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue