diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 4b8a534767..6789e7d8ae 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -444,18 +444,14 @@ void application_impl::startup() if( _options->count("api-access") ) { - if(fc::exists(_options->at("api-access").as())) - { - _apiaccess = fc::json::from_file( _options->at("api-access").as() ).as( 20 ); - ilog( "Using api access file from ${path}", - ("path", _options->at("api-access").as().string()) ); - } - else - { - elog("Failed to load file from ${path}", - ("path", _options->at("api-access").as().string())); - std::exit(EXIT_FAILURE); - } + fc::path api_access_file = _options->at("api-access").as(); + + FC_ASSERT( fc::exists(api_access_file), + "Failed to load file from ${path}", ("path", api_access_file) ); + + _apiaccess = fc::json::from_file( api_access_file ).as( 20 ); + ilog( "Using api access file from ${path}", + ("path", api_access_file) ); } else { @@ -984,10 +980,6 @@ void application::set_program_options(boost::program_options::options_descriptio ; command_line_options.add(configuration_file_options); command_line_options.add_options() - ("create-genesis-json", bpo::value(), - "Path to create a Genesis State at. If a well-formed JSON file exists at the path, it will be parsed and any " - "missing fields in a Genesis State will be added, and any unknown fields will be removed. If no file or an " - "invalid file is found, it will be replaced with an example Genesis State.") ("replay-blockchain", "Rebuild object graph by replaying all blocks without validation") ("revalidate-blockchain", "Rebuild object graph by replaying all blocks with full validation") ("resync-blockchain", "Delete all blocks and re-sync with network from scratch") @@ -1004,31 +996,6 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti my->_data_dir = data_dir; my->_options = &options; - if( options.count("create-genesis-json") ) - { - fc::path genesis_out = options.at("create-genesis-json").as(); - genesis_state_type genesis_state = detail::create_example_genesis(); - if( fc::exists(genesis_out) ) - { - try { - genesis_state = fc::json::from_file(genesis_out).as( 20 ); - } catch(const fc::exception& e) { - std::cerr << "Unable to parse existing genesis file:\n" << e.to_string() - << "\nWould you like to replace it? [y/N] "; - char response = std::cin.get(); - if( toupper(response) != 'Y' ) - return; - } - - std::cerr << "Updating genesis state in file " << genesis_out.generic_string() << "\n"; - } else { - std::cerr << "Creating example genesis state in file " << genesis_out.generic_string() << "\n"; - } - fc::json::save_to_file(genesis_state, genesis_out); - - std::exit(EXIT_SUCCESS); - } - if ( options.count("io-threads") ) { const uint16_t num_threads = options["io-threads"].as(); @@ -1039,7 +1006,7 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti void application::startup() { try { - my->startup(); + my->startup(); } catch ( const fc::exception& e ) { elog( "${e}", ("e",e.to_detail_string()) ); throw; diff --git a/libraries/app/application_impl.hxx b/libraries/app/application_impl.hxx index 9f601bce79..2d5d48080d 100644 --- a/libraries/app/application_impl.hxx +++ b/libraries/app/application_impl.hxx @@ -36,7 +36,7 @@ class application_impl : public net::node_delegate { } - ~application_impl() + virtual ~application_impl() { } diff --git a/libraries/chain/db_management.cpp b/libraries/chain/db_management.cpp index 231cc3ebc9..16e38f43da 100644 --- a/libraries/chain/db_management.cpp +++ b/libraries/chain/db_management.cpp @@ -223,6 +223,9 @@ void database::open( void database::close(bool rewind) { + if (!_opened) + return; + // TODO: Save pending tx's on close() clear_pending(); diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index b13fafff92..a3bcc2b5e2 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -175,6 +175,7 @@ int main(int argc, char** argv) { node.initialize_plugins( options ); node.startup(); + node.startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); @@ -188,10 +189,11 @@ int main(int argc, char** argv) { int signal = exit_promise->wait(); ilog("Exiting from signal ${n}", ("n", signal)); node.shutdown_plugins(); - return 0; + node.shutdown(); + return EXIT_SUCCESS; } catch( const fc::exception& e ) { elog("Exiting with error:\n${e}", ("e", e.to_detail_string())); - return 1; + return EXIT_FAILURE; } } diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 336639b1ba..cc10ecca01 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -137,6 +137,7 @@ int main(int argc, char** argv) { app::load_configuration_options(data_dir, cfg_options, options); bpo::notify(options); + node->initialize(data_dir, options); node->initialize_plugins( options ); @@ -163,7 +164,7 @@ int main(int argc, char** argv) { node->shutdown_plugins(); node->shutdown(); delete node; - return 0; + return EXIT_SUCCESS; } catch( const fc::exception& e ) { // deleting the node can yield, so do this outside the exception handler unhandled_exception = e; @@ -174,7 +175,7 @@ int main(int argc, char** argv) { elog("Exiting with error:\n${e}", ("e", unhandled_exception->to_detail_string())); node->shutdown(); delete node; - return 1; + return EXIT_FAILURE; } }