Skip to content

Commit

Permalink
Allow required plugins
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nathanielhourt committed Nov 7, 2018
1 parent e957b5f commit 5220425
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions libraries/app/include/graphene/app/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,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<typename PluginType>
std::shared_ptr<PluginType> register_plugin()
{
std::shared_ptr<PluginType> register_plugin(bool auto_load = false) {
auto plug = std::make_shared<PluginType>();
plug->plugin_set_app(this);

Expand All @@ -73,6 +72,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<abstract_plugin> get_plugin( const string& name )const;
Expand Down

0 comments on commit 5220425

Please sign in to comment.