From a175ac93c3ed5287e7151db7099b025e295797f5 Mon Sep 17 00:00:00 2001 From: clemahieu Date: Sun, 22 Jan 2017 22:28:52 -0600 Subject: [PATCH] account_exists needs to be transactional Adding ledger::forked_block as a utility function to retrieve the block with which block_a conflicts in the local ledger. Since this could be either an open_block fork or normal fork, which have different semantics. Testing to make sure a forked open_block will bootstrap correctly. Initializing QApplication before it's required which isn't alway supported. --- rai/rai_wallet/entry.cpp | 68 +++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/rai/rai_wallet/entry.cpp b/rai/rai_wallet/entry.cpp index 8b979111..1c5cb9b9 100644 --- a/rai/rai_wallet/entry.cpp +++ b/rai/rai_wallet/entry.cpp @@ -189,9 +189,8 @@ bool update_config (qt_wallet_config & config_a, boost::filesystem::path const & } } -int run_wallet (int argc, char * const * argv) +int run_wallet (QApplication & application, int argc, char * const * argv) { - QApplication application (argc, const_cast (argv)); auto working (rai::working_path ()); boost::filesystem::create_directories (working); qt_wallet_config config (working); @@ -273,34 +272,47 @@ int run_wallet (int argc, char * const * argv) int main (int argc, char * const * argv) { - boost::program_options::options_description description ("Command line options"); - description.add_options () ("help", "Print out options"); - rai::add_node_options (description); - boost::program_options::variables_map vm; - boost::program_options::store (boost::program_options::command_line_parser (argc, argv).options (description).allow_unregistered ().run (), vm); - boost::program_options::notify (vm); - int result (0); - if (!rai::handle_node_options (vm)) + try { + QApplication application (argc, const_cast (argv)); + boost::program_options::options_description description ("Command line options"); + description.add_options () ("help", "Print out options"); + rai::add_node_options (description); + boost::program_options::variables_map vm; + boost::program_options::store (boost::program_options::command_line_parser (argc, argv).options (description).allow_unregistered ().run (), vm); + boost::program_options::notify (vm); + int result (0); + if (!rai::handle_node_options (vm)) + { + } + else if (vm.count ("help") != 0) + { + std::cout << description << std::endl; + } + else + { + try + { + result = run_wallet (application, argc, argv); + } + catch (std::exception const & e) + { + show_error (boost::str (boost::format ("Exception while running wallet: %1%") % e.what ())); + } + catch (...) + { + show_error ("Unknown exception while running wallet"); + } + } + return result; } - else if (vm.count ("help") != 0) + catch (std::exception const & e) { - std::cout << description << std::endl; + std::cerr << boost::str (boost::format ("Exception while initializing %1%") % e.what ()); } - else - { - try - { - result = run_wallet (argc, argv); - } - catch (std::exception const & e) - { - show_error (boost::str (boost::format ("Exception while running wallet: %1%") % e.what ())); - } - catch (...) - { - show_error ("Unknown exception while running wallet"); - } - } - return result; + catch (std::exception const & e) + { + std::cerr << boost::str (boost::format ("Unknown exception while initializing %1%") % e.what ()); + } + return 1; }