From 0abcff9fb8b6d7e369e61bd09557ca3bd1ae2d51 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 7 Nov 2018 08:05:21 -0600 Subject: [PATCH 01/14] Allow required plugins As far as I can tell, there was no way previously for an application to register a plugin and ensure that plugin got loaded -- it would be necessary to manually edit the config and specify the plugin be loaded. This is suboptimal; if third party code wishes to track third party extensions on the blockchain, the correct way to do this is with a plugin, and this third party build should be able to load these required plugins regardless of whether the config lists them or not. This commit adds a boolean parameter to application::register_plugin which defaults to false for backwards compatibility; however, if set to true, the plugin will automatically be enabled when the app initializes. --- .../app/include/graphene/app/application.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index 4892bb9a27..bea72bf8ed 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -48,18 +48,17 @@ namespace graphene { namespace app { application(); ~application(); - void set_program_options( boost::program_options::options_description& command_line_options, - boost::program_options::options_description& configuration_file_options )const; - void initialize(const fc::path& data_dir, const boost::program_options::variables_map&options); - void initialize_plugins( const boost::program_options::variables_map& options ); + void set_program_options(boost::program_options::options_description& command_line_options, + boost::program_options::options_description& configuration_file_options)const; + void initialize(const fc::path& data_dir, const boost::program_options::variables_map& options); + void initialize_plugins(const boost::program_options::variables_map& options); void startup(); void shutdown(); void startup_plugins(); void shutdown_plugins(); template - std::shared_ptr register_plugin() - { + std::shared_ptr register_plugin(bool auto_load = false) { auto plug = std::make_shared(); plug->plugin_set_app(this); @@ -72,6 +71,10 @@ namespace graphene { namespace app { _cfg_options.add(plugin_cfg_options); add_available_plugin( plug ); + + if (auto_load) + enable_plugin(plug->plugin_name()); + return plug; } std::shared_ptr get_plugin( const string& name )const; From b5362ceddb5d6d793a5ff943e4b8a9e180cb7f60 Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Wed, 7 Nov 2018 20:28:09 -0600 Subject: [PATCH 02/14] Clean up plugin loader That code was nasty and... kinda wrong. So fix it up all shiny-like. But I also removed the super annoying default "wanted" plugins list, which only causes problems for third parties like me, and in general is just poor form. In my opinion, 5220425d433c1ce7af4f3b243655d74afa6c4e7a provides a much cleaner way to do this, in a way that is friendly rather than hostile to third parties. Would Be Nice: A generalized plugin conflict system added at the abstract_plugin level, so, for example, the elasticsearch plugin can conflict account_history and we deal with this in a general fashion rather than having this dirty special case check here. --- libraries/app/application.cpp | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index b77da4b711..98d187763a 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -1007,31 +1007,17 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti fc::asio::default_io_service_scope::set_num_threads(num_threads); } - std::vector wanted; - if( options.count("plugins") ) - { - boost::split(wanted, options.at("plugins").as(), [](char c){return c == ' ';}); - } - else - { - wanted.push_back("witness"); - wanted.push_back("account_history"); - wanted.push_back("market_history"); - wanted.push_back("grouped_orders"); - } - int es_ah_conflict_counter = 0; - for (auto& it : wanted) - { - if(it == "account_history") - ++es_ah_conflict_counter; - if(it == "elasticsearch") - ++es_ah_conflict_counter; + if (options.count("plugins")) { + std::set plugins; + boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); - if(es_ah_conflict_counter > 1) { - elog("Can't start program with elasticsearch and account_history plugin at the same time"); - std::exit(EXIT_FAILURE); - } - if (!it.empty()) enable_plugin(it); + FC_ASSERT(!(plugins.count("account_history") && plugins.count("elasticsearch")), + "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin"); + + std::for_each(plugins.begin(), plugins.end(), [this](const string& plug) mutable { + if (!plug.empty()) + enable_plugin(plug); + }); } } From f5031bde96c5f3e20fc71c1d34a519bb417e850d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 15 Nov 2018 17:54:24 -0300 Subject: [PATCH 03/14] move plugins option to witness_node executable --- libraries/app/application.cpp | 14 --------- .../app/include/graphene/app/application.hpp | 3 +- programs/witness_node/main.cpp | 31 +++++++++++++++++-- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/libraries/app/application.cpp b/libraries/app/application.cpp index 98d187763a..62748a7bcb 100644 --- a/libraries/app/application.cpp +++ b/libraries/app/application.cpp @@ -947,7 +947,6 @@ void application::set_program_options(boost::program_options::options_descriptio ("genesis-json", bpo::value(), "File to read Genesis State from") ("dbg-init-key", bpo::value(), "Block signing key to use for init witnesses, overrides genesis file") ("api-access", bpo::value(), "JSON file specifying API permissions") - ("plugins", bpo::value(), "Space-separated list of plugins to activate") ("io-threads", bpo::value()->implicit_value(0), "Number of IO threads, default to 0 for auto-configuration") ("enable-subscribe-to-all", bpo::value()->implicit_value(true), "Whether allow API clients to subscribe to universal object creation and removal events") @@ -1006,19 +1005,6 @@ void application::initialize(const fc::path& data_dir, const boost::program_opti const uint16_t num_threads = options["io-threads"].as(); fc::asio::default_io_service_scope::set_num_threads(num_threads); } - - if (options.count("plugins")) { - std::set plugins; - boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); - - FC_ASSERT(!(plugins.count("account_history") && plugins.count("elasticsearch")), - "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin"); - - std::for_each(plugins.begin(), plugins.end(), [this](const string& plug) mutable { - if (!plug.empty()) - enable_plugin(plug); - }); - } } void application::startup() diff --git a/libraries/app/include/graphene/app/application.hpp b/libraries/app/include/graphene/app/application.hpp index bea72bf8ed..66a73f3999 100644 --- a/libraries/app/include/graphene/app/application.hpp +++ b/libraries/app/include/graphene/app/application.hpp @@ -101,8 +101,9 @@ namespace graphene { namespace app { const application_options& get_options(); - private: void enable_plugin( const string& name ); + + private: void add_available_plugin( std::shared_ptr p ); std::shared_ptr my; diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 07c17a9010..3141c0957a 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -66,7 +67,7 @@ int main(int argc, char** argv) { ("help,h", "Print this help message and exit.") ("data-dir,d", bpo::value()->default_value("witness_node_data_dir"), "Directory containing databases, configuration file, etc.") ("version,v", "Display version information") - ; + ("plugins", bpo::value(), "Space-separated list of plugins to activate"); bpo::variables_map options; @@ -90,10 +91,34 @@ int main(int argc, char** argv) { } catch (const boost::program_options::error& e) { - std::cerr << "Error parsing command line: " << e.what() << "\n"; - return 1; + std::cerr << "Error parsing command line: " << e.what() << "\n"; + return 1; } + if (options.count("plugins")) { + + std::set plugins; + boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); + + if(plugins.count("account_history") && plugins.count("elasticsearch")) { + std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; + return 1; + } + + std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { + if (!plug.empty()) { + node->enable_plugin(plug); + } + }); + } + else { + node->enable_plugin("witness"); + node->enable_plugin("account_history"); + node->enable_plugin("market_history"); + node->enable_plugin("grouped_orders"); + } + + if( options.count("help") ) { std::cout << app_options << "\n"; From adef6a2984c13ce882261036a01ba610fe11ff1d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 15 Nov 2018 18:54:02 -0300 Subject: [PATCH 04/14] fix cli wallet test --- tests/cli/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 393dce4d83..16b29e125d 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -114,10 +114,10 @@ int get_available_port() std::shared_ptr start_application(fc::temp_directory& app_dir, int& server_port_number) { std::shared_ptr app1(new graphene::app::application{}); - app1->register_plugin(); - app1->register_plugin< graphene::market_history::market_history_plugin >(); - app1->register_plugin< graphene::witness_plugin::witness_plugin >(); - app1->register_plugin< graphene::grouped_orders::grouped_orders_plugin>(); + app1->register_plugin(true); + app1->register_plugin< graphene::market_history::market_history_plugin >(true); + app1->register_plugin< graphene::witness_plugin::witness_plugin >(true); + app1->register_plugin< graphene::grouped_orders::grouped_orders_plugin>(true); app1->startup_plugins(); boost::program_options::variables_map cfg; #ifdef _WIN32 From 9647ad117b297aad4885565d4dedf9393a0f9917 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Thu, 15 Nov 2018 19:28:56 -0300 Subject: [PATCH 05/14] remove double space line --- programs/witness_node/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 3141c0957a..05679766b6 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -117,8 +117,7 @@ int main(int argc, char** argv) { node->enable_plugin("market_history"); node->enable_plugin("grouped_orders"); } - - + if( options.count("help") ) { std::cout << app_options << "\n"; From ce35a798669660fa1515f536a9e9b319eae47d48 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sat, 17 Nov 2018 19:02:57 -0300 Subject: [PATCH 06/14] add default plugin values to option --- programs/witness_node/main.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index 05679766b6..f0fd5da66a 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -65,9 +65,11 @@ int main(int argc, char** argv) { bpo::options_description cfg_options("Graphene Witness Node"); app_options.add_options() ("help,h", "Print this help message and exit.") - ("data-dir,d", bpo::value()->default_value("witness_node_data_dir"), "Directory containing databases, configuration file, etc.") + ("data-dir,d", bpo::value()->default_value("witness_node_data_dir"), + "Directory containing databases, configuration file, etc.") ("version,v", "Display version information") - ("plugins", bpo::value(), "Space-separated list of plugins to activate"); + ("plugins", bpo::value()->default_value("witness account_history market_history grouped_orders"), + "Space-separated list of plugins to activate"); bpo::variables_map options; @@ -111,12 +113,6 @@ int main(int argc, char** argv) { } }); } - else { - node->enable_plugin("witness"); - node->enable_plugin("account_history"); - node->enable_plugin("market_history"); - node->enable_plugin("grouped_orders"); - } if( options.count("help") ) { From 58ad814bc74992153e668ed6911c72f4a214d700 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Sun, 18 Nov 2018 11:05:18 -0300 Subject: [PATCH 07/14] remove not needed check --- programs/witness_node/main.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/programs/witness_node/main.cpp b/programs/witness_node/main.cpp index f0fd5da66a..336639b1ba 100644 --- a/programs/witness_node/main.cpp +++ b/programs/witness_node/main.cpp @@ -97,22 +97,19 @@ int main(int argc, char** argv) { return 1; } - if (options.count("plugins")) { + std::set plugins; + boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); - std::set plugins; - boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); + if(plugins.count("account_history") && plugins.count("elasticsearch")) { + std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; + return 1; + } - if(plugins.count("account_history") && plugins.count("elasticsearch")) { - std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; - return 1; + std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { + if (!plug.empty()) { + node->enable_plugin(plug); } - - std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { - if (!plug.empty()) { - node->enable_plugin(plug); - } - }); - } + }); if( options.count("help") ) { From 7089d2a95b76e0263ce1c34700db2c084ab1395b Mon Sep 17 00:00:00 2001 From: Alfredo Date: Fri, 30 Nov 2018 16:35:40 -0300 Subject: [PATCH 08/14] fix delayed node --- programs/delayed_node/main.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 0ba1e6944d..137ae22627 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -60,7 +60,7 @@ fc::optional load_logging_config_from_ini_file(const fc::pat int main(int argc, char** argv) { try { - app::application node; + app::application* node = new app::application(); bpo::options_description app_options("Graphene Delayed Node"); bpo::options_description cfg_options("Graphene Delayed Node"); app_options.add_options() @@ -70,14 +70,14 @@ int main(int argc, char** argv) { bpo::variables_map options; - auto delayed_plug = node.register_plugin(); - auto history_plug = node.register_plugin(); - auto market_history_plug = node.register_plugin(); + auto delayed_plug = node->register_plugin(); + auto history_plug = node->register_plugin(); + auto market_history_plug = node->register_plugin(); try { bpo::options_description cli, cfg; - node.set_program_options(cli, cfg); + node->set_program_options(cli, cfg); app_options.add(cli); cfg_options.add(cfg); bpo::store(bpo::parse_command_line(argc, argv, app_options), options); @@ -88,6 +88,13 @@ int main(int argc, char** argv) { return 1; } + std::set plugins = {"delayed_node", "account_history", "market_history"}; + std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { + if (!plug.empty()) { + node->enable_plugin(plug); + } + }); + if( options.count("help") ) { std::cout << app_options << "\n"; @@ -160,26 +167,24 @@ int main(int argc, char** argv) { elog("Error parsing configuration file: ${e}", ("e", e.what())); return 1; } - if( !options.count("plugins") ) - options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); - node.initialize(data_dir, options); - node.initialize_plugins( options ); + node->initialize(data_dir, options); + node->initialize_plugins( options ); - node.startup(); - node.startup_plugins(); + node->startup(); + node->startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { exit_promise->set_value(signal); }, SIGINT); - ilog("Started delayed node on a chain with ${h} blocks.", ("h", node.chain_database()->head_block_num())); - ilog("Chain ID is ${id}", ("id", node.chain_database()->get_chain_id()) ); + ilog("Started delayed node on a chain with ${h} blocks.", ("h", node->chain_database()->head_block_num())); + ilog("Chain ID is ${id}", ("id", node->chain_database()->get_chain_id()) ); int signal = exit_promise->wait(); ilog("Exiting from signal ${n}", ("n", signal)); - node.shutdown_plugins(); + node->shutdown_plugins(); return 0; } catch( const fc::exception& e ) { elog("Exiting with error:\n${e}", ("e", e.to_detail_string())); From 1dd719f94ddadcbf13486494d8c2eb1b8eb8d566 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 5 Dec 2018 10:02:21 -0300 Subject: [PATCH 09/14] use auto load plugins in delayed node --- programs/delayed_node/main.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 137ae22627..311911adcb 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -70,9 +70,9 @@ int main(int argc, char** argv) { bpo::variables_map options; - auto delayed_plug = node->register_plugin(); - auto history_plug = node->register_plugin(); - auto market_history_plug = node->register_plugin(); + auto delayed_plug = node->register_plugin(true); + auto history_plug = node->register_plugin(true); + auto market_history_plug = node->register_plugin(true); try { @@ -88,13 +88,6 @@ int main(int argc, char** argv) { return 1; } - std::set plugins = {"delayed_node", "account_history", "market_history"}; - std::for_each(plugins.begin(), plugins.end(), [node](const std::string& plug) mutable { - if (!plug.empty()) { - node->enable_plugin(plug); - } - }); - if( options.count("help") ) { std::cout << app_options << "\n"; From a8020a7da022cf8ec24063b64a84a46a06ab82c8 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 17 Dec 2018 10:46:38 -0300 Subject: [PATCH 10/14] reverse delayed node and only add auto to needed plugins --- programs/delayed_node/main.cpp | 50 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 311911adcb..a8ef7daddb 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -60,32 +60,32 @@ fc::optional load_logging_config_from_ini_file(const fc::pat int main(int argc, char** argv) { try { - app::application* node = new app::application(); + app::application node; bpo::options_description app_options("Graphene Delayed Node"); bpo::options_description cfg_options("Graphene Delayed Node"); app_options.add_options() - ("help,h", "Print this help message and exit.") - ("data-dir,d", bpo::value()->default_value("delayed_node_data_dir"), "Directory containing databases, configuration file, etc.") - ; + ("help,h", "Print this help message and exit.") + ("data-dir,d", bpo::value()->default_value("delayed_node_data_dir"), "Directory containing databases, configuration file, etc.") + ; bpo::variables_map options; - auto delayed_plug = node->register_plugin(true); - auto history_plug = node->register_plugin(true); - auto market_history_plug = node->register_plugin(true); + auto delayed_plug = node.register_plugin(true); + auto history_plug = node.register_plugin(true); + auto market_history_plug = node.register_plugin(true); try { bpo::options_description cli, cfg; - node->set_program_options(cli, cfg); + node.set_program_options(cli, cfg); app_options.add(cli); cfg_options.add(cfg); bpo::store(bpo::parse_command_line(argc, argv, app_options), options); } catch (const boost::program_options::error& e) { - std::cerr << "Error parsing command line: " << e.what() << "\n"; - return 1; + std::cerr << "Error parsing command line: " << e.what() << "\n"; + return 1; } if( options.count("help") ) @@ -160,24 +160,26 @@ int main(int argc, char** argv) { elog("Error parsing configuration file: ${e}", ("e", e.what())); return 1; } + if( !options.count("plugins") ) + options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); - node->initialize(data_dir, options); - node->initialize_plugins( options ); + node.initialize(data_dir, options); + node.initialize_plugins( options ); - node->startup(); - node->startup_plugins(); + node.startup(); + node.startup_plugins(); fc::promise::ptr exit_promise = new fc::promise("UNIX Signal Handler"); fc::set_signal_handler([&exit_promise](int signal) { - exit_promise->set_value(signal); + exit_promise->set_value(signal); }, SIGINT); - ilog("Started delayed node on a chain with ${h} blocks.", ("h", node->chain_database()->head_block_num())); - ilog("Chain ID is ${id}", ("id", node->chain_database()->get_chain_id()) ); + ilog("Started delayed node on a chain with ${h} blocks.", ("h", node.chain_database()->head_block_num())); + ilog("Chain ID is ${id}", ("id", node.chain_database()->get_chain_id()) ); int signal = exit_promise->wait(); ilog("Exiting from signal ${n}", ("n", signal)); - node->shutdown_plugins(); + node.shutdown_plugins(); return 0; } catch( const fc::exception& e ) { elog("Exiting with error:\n${e}", ("e", e.to_detail_string())); @@ -239,14 +241,14 @@ fc::optional load_logging_config_from_ini_file(const fc::pat // stdout/stderr will be taken from ini file, everything else hard-coded here fc::console_appender::config console_appender_config; console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::debug, - fc::console_appender::color::green)); + fc::console_appender::level_color(fc::log_level::debug, + fc::console_appender::color::green)); console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::warn, - fc::console_appender::color::brown)); + fc::console_appender::level_color(fc::log_level::warn, + fc::console_appender::color::brown)); console_appender_config.level_colors.emplace_back( - fc::console_appender::level_color(fc::log_level::error, - fc::console_appender::color::cyan)); + fc::console_appender::level_color(fc::log_level::error, + fc::console_appender::color::cyan)); console_appender_config.stream = fc::variant(stream_name, 1).as(1); logging_config.appenders.push_back(fc::appender_config(console_appender_name, "console", fc::variant(console_appender_config, GRAPHENE_MAX_NESTED_OBJECTS))); found_logging_config = true; From 1326a5c126d8fcf99cfa717925dac58c0bbb0a0d Mon Sep 17 00:00:00 2001 From: Alfredo Date: Mon, 17 Dec 2018 11:15:13 -0300 Subject: [PATCH 11/14] make plugins option work in delayed --- programs/delayed_node/main.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index a8ef7daddb..4a43535ac6 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -66,13 +66,15 @@ int main(int argc, char** argv) { app_options.add_options() ("help,h", "Print this help message and exit.") ("data-dir,d", bpo::value()->default_value("delayed_node_data_dir"), "Directory containing databases, configuration file, etc.") + ("plugins", bpo::value()->default_value("delayed_node account_history market_history"), + "Space-separated list of plugins to activate"); ; bpo::variables_map options; - auto delayed_plug = node.register_plugin(true); - auto history_plug = node.register_plugin(true); - auto market_history_plug = node.register_plugin(true); + auto delayed_plug = node.register_plugin(); + auto history_plug = node.register_plugin(); + auto market_history_plug = node.register_plugin(); try { @@ -160,9 +162,20 @@ int main(int argc, char** argv) { elog("Error parsing configuration file: ${e}", ("e", e.what())); return 1; } - if( !options.count("plugins") ) - options.insert( std::make_pair( "plugins", bpo::variable_value(std::string("delayed_node account_history market_history"), true) ) ); + std::set plugins; + boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); + + if(plugins.count("account_history") && plugins.count("elasticsearch")) { + std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; + return 1; + } + + std::for_each(plugins.begin(), plugins.end(), [&](const std::string& plug) mutable { + if (!plug.empty()) { + node.enable_plugin(plug); + } + }); node.initialize(data_dir, options); node.initialize_plugins( options ); From a590c25c52573d2391a44bb532d1a10c8e791edd Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 16 Jan 2019 10:58:30 -0300 Subject: [PATCH 12/14] remove useless check --- programs/delayed_node/main.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/programs/delayed_node/main.cpp b/programs/delayed_node/main.cpp index 4a43535ac6..b13fafff92 100644 --- a/programs/delayed_node/main.cpp +++ b/programs/delayed_node/main.cpp @@ -166,11 +166,6 @@ int main(int argc, char** argv) { std::set plugins; boost::split(plugins, options.at("plugins").as(), [](char c){return c == ' ';}); - if(plugins.count("account_history") && plugins.count("elasticsearch")) { - std::cerr << "Plugin conflict: Cannot load both account_history plugin and elasticsearch plugin\n"; - return 1; - } - std::for_each(plugins.begin(), plugins.end(), [&](const std::string& plug) mutable { if (!plug.empty()) { node.enable_plugin(plug); From caf7f7fe99aa9b53898ced00effd0142204f46c9 Mon Sep 17 00:00:00 2001 From: Alfredo Date: Wed, 16 Jan 2019 10:59:02 -0300 Subject: [PATCH 13/14] add default value to trusted-node --- libraries/plugins/delayed_node/delayed_node_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index 24a46cc066..57b271b896 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -58,7 +58,7 @@ delayed_node_plugin::~delayed_node_plugin() void delayed_node_plugin::plugin_set_program_options(bpo::options_description& cli, bpo::options_description& cfg) { cli.add_options() - ("trusted-node", boost::program_options::value(), "RPC endpoint of a trusted validating node (required)") + ("trusted-node", boost::program_options::value()->default_value("127.0.0.1:8090"), "RPC endpoint of a trusted validating node (required)") ; cfg.add(cli); } From e198552d0dd1a36dd68067b16195dc4706bc740c Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Thu, 17 Jan 2019 12:37:30 -0300 Subject: [PATCH 14/14] remove default option in delayed plugin --- libraries/plugins/delayed_node/delayed_node_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/plugins/delayed_node/delayed_node_plugin.cpp b/libraries/plugins/delayed_node/delayed_node_plugin.cpp index 9fec61c8c5..0329d018b2 100644 --- a/libraries/plugins/delayed_node/delayed_node_plugin.cpp +++ b/libraries/plugins/delayed_node/delayed_node_plugin.cpp @@ -58,7 +58,7 @@ delayed_node_plugin::~delayed_node_plugin() void delayed_node_plugin::plugin_set_program_options(bpo::options_description& cli, bpo::options_description& cfg) { cli.add_options() - ("trusted-node", boost::program_options::value()->default_value("127.0.0.1:8090"), "RPC endpoint of a trusted validating node (required for delayed_node)") + ("trusted-node", boost::program_options::value(), "RPC endpoint of a trusted validating node (required for delayed_node)") ; cfg.add(cli); }