Skip to content

Commit

Permalink
Merge pull request #2106 from AntelopeIO/chain_api_plugin_check_50
Browse files Browse the repository at this point in the history
[5.0] more robust `chain_api_plugin` check in `producer_plugin`
  • Loading branch information
spoonincode authored Jan 19, 2024
2 parents 76c3b63 + bb8400d commit b0ce27e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions plugins/producer_plugin/producer_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>();
} else if (_producers.empty()) {
if (options.count("plugin")) {
const auto& v = options.at("plugin").as<std::vector<std::string>>();
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 (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));
}
}
EOS_ASSERT(producer_plugin::test_mode_ || _ro_thread_pool_size == 0 || _producers.empty(), plugin_config_exception,
Expand Down

0 comments on commit b0ce27e

Please sign in to comment.