forked from lthn/blockchain
--stop-after-height implemented
This commit is contained in:
parent
cee1e58de8
commit
3520e17836
8 changed files with 33 additions and 0 deletions
|
|
@ -13,6 +13,8 @@ namespace command_line
|
|||
const arg_descriptor<bool> arg_help = {"help", "Produce help message"};
|
||||
const arg_descriptor<bool> arg_version = {"version", "Output version information"};
|
||||
const arg_descriptor<std::string> arg_data_dir = {"data-dir", "Specify data directory", ""};
|
||||
|
||||
const arg_descriptor<int> arg_stop_after_height = { "stop-after-height", "If specified, the daemon will stop immediately after a block with the given height is added", 0 };
|
||||
|
||||
const arg_descriptor<std::string> arg_config_file = { "config-file", "Specify configuration file", std::string(CURRENCY_NAME_SHORT ".conf") };
|
||||
const arg_descriptor<bool> arg_os_version = { "os-version", "" };
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ namespace command_line
|
|||
extern const arg_descriptor<bool> arg_help;
|
||||
extern const arg_descriptor<bool> arg_version;
|
||||
extern const arg_descriptor<std::string> arg_data_dir;
|
||||
extern const arg_descriptor<int> arg_stop_after_height;
|
||||
extern const arg_descriptor<std::string> arg_config_file;
|
||||
extern const arg_descriptor<bool> arg_os_version;
|
||||
extern const arg_descriptor<std::string> arg_log_dir;
|
||||
|
|
|
|||
|
|
@ -75,6 +75,11 @@ namespace currency
|
|||
bool core::handle_command_line(const boost::program_options::variables_map& vm)
|
||||
{
|
||||
m_config_folder = command_line::get_arg(vm, command_line::arg_data_dir);
|
||||
m_stop_after_height = static_cast<uint64_t>(command_line::get_arg(vm, command_line::arg_stop_after_height));
|
||||
if (m_stop_after_height != 0)
|
||||
{
|
||||
LOG_PRINT_YELLOW("Daemon will STOP after block " << m_stop_after_height, LOG_LEVEL_0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
|
|
@ -502,6 +507,14 @@ namespace currency
|
|||
{ LOG_PRINT_GREEN("Hardfork 1 activated at height " << h, LOG_LEVEL_0); }
|
||||
else if (h == crc.hard_fork_02_starts_after_height + 1)
|
||||
{ LOG_PRINT_GREEN("Hardfork 2 activated at height " << h, LOG_LEVEL_0); }
|
||||
|
||||
if (h == m_stop_after_height)
|
||||
{
|
||||
LOG_PRINT_YELLOW("Reached block " << h << ", the daemon will now stop as requested", LOG_LEVEL_0);
|
||||
if (m_critical_error_handler)
|
||||
return m_critical_error_handler->on_immediate_stop_requested();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ namespace currency
|
|||
miner m_miner;
|
||||
account_public_address m_miner_address;
|
||||
std::string m_config_folder;
|
||||
uint64_t m_stop_after_height;
|
||||
currency_protocol_stub m_protocol_stub;
|
||||
math_helper::once_a_time_seconds<60*60*12, false> m_prune_alt_blocks_interval;
|
||||
math_helper::once_a_time_seconds<60, true> m_check_free_space_interval;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ namespace currency
|
|||
virtual bool on_critical_time_sync_error() = 0;
|
||||
|
||||
virtual bool on_critical_low_free_space(uint64_t available, uint64_t required) = 0;
|
||||
|
||||
virtual bool on_immediate_stop_requested() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,16 @@ struct core_critical_error_handler_t : public currency::i_critical_error_handler
|
|||
*/
|
||||
}
|
||||
|
||||
virtual bool on_immediate_stop_requested() override
|
||||
{
|
||||
LOG_PRINT_L0(ENDL << ENDL << "immediate daemon stop requested, stopping..." << ENDL << ENDL);
|
||||
|
||||
dch.stop_handling();
|
||||
p2psrv.send_stop_signal();
|
||||
return true; // the caller must stop processing
|
||||
}
|
||||
|
||||
|
||||
daemon_commands_handler& dch;
|
||||
p2psrv_t& p2psrv;
|
||||
bool dont_stop_on_time_error;
|
||||
|
|
@ -137,6 +147,7 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_cmd_only, command_line::arg_os_version);
|
||||
// tools::get_default_data_dir() can't be called during static initialization
|
||||
command_line::add_arg(desc_cmd_only, command_line::arg_data_dir, tools::get_default_data_dir());
|
||||
command_line::add_arg(desc_cmd_only, command_line::arg_stop_after_height);
|
||||
command_line::add_arg(desc_cmd_only, command_line::arg_config_file);
|
||||
command_line::add_arg(desc_cmd_only, command_line::arg_disable_upnp);
|
||||
|
||||
|
|
|
|||
|
|
@ -117,6 +117,7 @@ bool wallets_manager::init_command_line(int argc, char* argv[])
|
|||
command_line::add_arg(desc_cmd_only, command_line::arg_os_version);
|
||||
// tools::get_default_data_dir() can't be called during static initialization
|
||||
command_line::add_arg(desc_cmd_only, command_line::arg_data_dir, tools::get_default_data_dir());
|
||||
command_line::add_arg(desc_cmd_only, command_line::arg_stop_after_height);
|
||||
command_line::add_arg(desc_cmd_only, command_line::arg_config_file);
|
||||
|
||||
command_line::add_arg(desc_cmd_sett, command_line::arg_log_dir);
|
||||
|
|
|
|||
|
|
@ -666,6 +666,8 @@ int main(int argc, char* argv[])
|
|||
command_line::add_arg(desc_options, arg_run_single_test);
|
||||
command_line::add_arg(desc_options, arg_enable_debug_asserts);
|
||||
command_line::add_arg(desc_options, command_line::arg_data_dir, std::string("."));
|
||||
command_line::add_arg(desc_options, command_line::arg_stop_after_height);
|
||||
|
||||
currency::core::init_options(desc_options);
|
||||
tools::db::db_backend_selector::init_options(desc_options);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue