From 576984b093583c8991cebcee99b723896c1cbf98 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Thu, 18 Jan 2024 12:16:04 -0500 Subject: [PATCH 1/2] different approach to detecting if chain_api_plugin enabled --- plugins/producer_plugin/producer_plugin.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index ae1019a52e..ef4b86f91b 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -1212,14 +1212,12 @@ void producer_plugin_impl::plugin_initialize(const boost::program_options::varia if (options.count("read-only-threads")) { _ro_thread_pool_size = options.at("read-only-threads").as(); } else if (_producers.empty()) { - if (options.count("plugin")) { - const auto& v = options.at("plugin").as>(); - auto i = std::find_if(v.cbegin(), v.cend(), [](const std::string& p) { return p == "eosio::chain_api_plugin"; }); - if (i != v.cend()) { - // default to 3 threads for non producer nodes running chain_api_plugin if not specified - _ro_thread_pool_size = 3; - ilog("chain_api_plugin configured, defaulting read-only-threads to ${t}", ("t", _ro_thread_pool_size)); - } + //appbase initializes configured plugins before auto-start plugins, so if chain_api_plugin is enabled it's + // initialized before producer_plugin (i.e. before this code here) + if (app().get_plugin("eosio::chain_api_plugin").get_state() == abstract_plugin::initialized) { + // default to 3 threads for non producer nodes running chain_api_plugin if not specified + _ro_thread_pool_size = 3; + ilog("chain_api_plugin configured, defaulting read-only-threads to ${t}", ("t", _ro_thread_pool_size)); } } EOS_ASSERT(producer_plugin::test_mode_ || _ro_thread_pool_size == 0 || _producers.empty(), plugin_config_exception, From bb8400db4de3e0d1e5d3cb49b6df9795fccd4502 Mon Sep 17 00:00:00 2001 From: Matt Witherspoon <32485495+spoonincode@users.noreply.github.com> Date: Thu, 18 Jan 2024 16:37:57 -0500 Subject: [PATCH 2/2] don't assume chain_api_plugin is linked --- plugins/producer_plugin/producer_plugin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/producer_plugin/producer_plugin.cpp b/plugins/producer_plugin/producer_plugin.cpp index ef4b86f91b..e1816ab24f 100644 --- a/plugins/producer_plugin/producer_plugin.cpp +++ b/plugins/producer_plugin/producer_plugin.cpp @@ -1214,7 +1214,7 @@ void producer_plugin_impl::plugin_initialize(const boost::program_options::varia } else if (_producers.empty()) { //appbase initializes configured plugins before auto-start plugins, so if chain_api_plugin is enabled it's // initialized before producer_plugin (i.e. before this code here) - if (app().get_plugin("eosio::chain_api_plugin").get_state() == abstract_plugin::initialized) { + if (abstract_plugin* capi = app().find_plugin("eosio::chain_api_plugin"); capi && capi->get_state() == abstract_plugin::initialized) { // default to 3 threads for non producer nodes running chain_api_plugin if not specified _ro_thread_pool_size = 3; ilog("chain_api_plugin configured, defaulting read-only-threads to ${t}", ("t", _ro_thread_pool_size));