-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve plugin loader #1427
Improve plugin loader #1427
Conversation
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.
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, 5220425 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is error in cli_test
:
/home/travis/build/bitshares/bitshares-core/tests/cli/main.cpp(552): error in "account_history_pagination": check 201 == history.size() failed [201 != 0]
This error is caused by if (options.count("plugins"))
, why did you remove else
branch ? what will be if there are no options.count("plugins")
? IMHO you should add in else
branch next snippet of code as was before:
plugins.emplace("witness");
plugins.emplace("account_history");
plugins.emplace("market_history");
plugins.emplace("grouped_orders");
and after that (I mean if/else
statement) we should use next snippet of code:
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);
});
Now the problem is in cli_test
that it cannot use account_history
plugin because it wasn't loaded.
final code looks something like next (
|
with my final code |
Thanks! IMO, with our current architecture, we don't need this functionality, as there are no mandatory plugins. All mandatory stuff is inside the core. We should not remove the default selection of plugins, because we don't want to break existing installations that rely on defaults. The conflict detection code looks better than before. |
closing this one as the best candidate is #1437 will be merged after getting 1 approval. |
move --plugins from application to binary #1427
Replaces #1424
This PR adds the ability for client code of the
application
class to request plugins be loaded automatically when it registers them. I don't know if upstream bitshares will want this or not, but here's a PR just in case!This PR is mostly a clean-up/correctness fix (the old conflict detection between the
account_history
andelasticsearch
plugins was clumsy and would false-positive if either plugin showed up twice in the list), but it does add the ability to mark plugins to be loaded automatically when they are registered.Please note that this PR does remove the hard-coded list of "wanted" plugins, as this shortcut is annoying to third party code, like that of Follow My Vote, which may not want to be cluttered up by having those plugins linked in. This may cause mild turbulence to existing environments which depend on this shortcut. #sorrynotsorry =) This turbulence can be avoided by calling
register_plugin(true)
for the desired auto-load plugins, however, doing so will prevent disabling these plugins from the config.