提交 40dbe633 编写于 作者: J Jonathan Giszczak

Self-registering plugins in eosiod.

main.cpp gets shorter, CMakeLists.txt gets longer, door opens for
conditional compilation of plugins.
上级 4db2357f
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
namespace eosio { namespace eosio {
static appbase::abstract_plugin& _chain_api_plugin = app().register_plugin<chain_api_plugin>();
using namespace eosio; using namespace eosio;
class chain_api_plugin_impl { class chain_api_plugin_impl {
......
...@@ -48,6 +48,8 @@ FC_REFLECT(eosio::detail::faucet_testnet_create_account_rate_limited_response, ( ...@@ -48,6 +48,8 @@ FC_REFLECT(eosio::detail::faucet_testnet_create_account_rate_limited_response, (
namespace eosio { namespace eosio {
static appbase::abstract_plugin& _faucet_testnet_plugin = app().register_plugin<faucet_testnet_plugin>();
using namespace eosio::chain; using namespace eosio::chain;
using public_key_type = chain::public_key_type; using public_key_type = chain::public_key_type;
using key_pair = std::pair<std::string, std::string>; using key_pair = std::pair<std::string, std::string>;
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include <memory> #include <memory>
namespace eosio { namespace eosio {
static appbase::abstract_plugin& _http_plugin = app().register_plugin<http_plugin>();
namespace asio = boost::asio; namespace asio = boost::asio;
using std::map; using std::map;
......
...@@ -19,6 +19,7 @@ FC_REFLECT(eosio::detail::net_api_plugin_empty, ); ...@@ -19,6 +19,7 @@ FC_REFLECT(eosio::detail::net_api_plugin_empty, );
namespace eosio { namespace eosio {
static appbase::abstract_plugin& _net_api_plugin = app().register_plugin<net_api_plugin>();
using namespace eosio; using namespace eosio;
......
...@@ -33,6 +33,8 @@ namespace fc { ...@@ -33,6 +33,8 @@ namespace fc {
} }
namespace eosio { namespace eosio {
static appbase::abstract_plugin& _net_plugin = app().register_plugin<net_plugin>();
using std::vector; using std::vector;
using boost::asio::ip::tcp; using boost::asio::ip::tcp;
...@@ -1337,7 +1339,7 @@ namespace eosio { ...@@ -1337,7 +1339,7 @@ namespace eosio {
auto socket = std::make_shared<tcp::socket>( std::ref( app().get_io_service() ) ); auto socket = std::make_shared<tcp::socket>( std::ref( app().get_io_service() ) );
acceptor->async_accept( *socket, [socket,this]( boost::system::error_code ec ) { acceptor->async_accept( *socket, [socket,this]( boost::system::error_code ec ) {
if( !ec ) { if( !ec ) {
int visitors = 0; uint32_t visitors = 0;
for (auto &conn : connections) { for (auto &conn : connections) {
if(conn->current() && conn->peer_addr.empty()) { if(conn->current() && conn->peer_addr.empty()) {
visitors++; visitors++;
......
...@@ -19,6 +19,8 @@ using std::vector; ...@@ -19,6 +19,8 @@ using std::vector;
namespace eosio { namespace eosio {
static appbase::abstract_plugin& _producer_plugin = app().register_plugin<producer_plugin>();
using namespace eosio::chain; using namespace eosio::chain;
class producer_plugin_impl { class producer_plugin_impl {
......
...@@ -22,6 +22,8 @@ FC_REFLECT(eosio::detail::txn_test_gen_empty, ); ...@@ -22,6 +22,8 @@ FC_REFLECT(eosio::detail::txn_test_gen_empty, );
namespace eosio { namespace eosio {
static appbase::abstract_plugin& _txn_test_gen_plugin = app().register_plugin<txn_test_gen_plugin>();
using namespace eosio::chain; using namespace eosio::chain;
#define CALL(api_name, api_handle, call_name, INVOKE, http_response_code) \ #define CALL(api_name, api_handle, call_name, INVOKE, http_response_code) \
......
...@@ -20,6 +20,7 @@ FC_REFLECT(eosio::detail::wallet_api_plugin_empty, ); ...@@ -20,6 +20,7 @@ FC_REFLECT(eosio::detail::wallet_api_plugin_empty, );
namespace eosio { namespace eosio {
static appbase::abstract_plugin& _wallet_api_plugin = app().register_plugin<wallet_api_plugin>();
using namespace eosio; using namespace eosio;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
*/ */
#include <eosio/wallet_plugin/wallet_plugin.hpp> #include <eosio/wallet_plugin/wallet_plugin.hpp>
#include <eosio/wallet_plugin/wallet_manager.hpp> #include <eosio/wallet_plugin/wallet_manager.hpp>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include <chrono> #include <chrono>
......
...@@ -31,10 +31,10 @@ target_include_directories(eosiod PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) ...@@ -31,10 +31,10 @@ target_include_directories(eosiod PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
target_link_libraries( eosiod target_link_libraries( eosiod
PRIVATE appbase PRIVATE appbase
# PRIVATE account_history_api_plugin account_history_plugin db_plugin # PRIVATE account_history_api_plugin account_history_plugin db_plugin
PRIVATE chain_api_plugin producer_plugin chain_plugin PRIVATE -Wl,--whole-archive chain_api_plugin -Wl,--no-whole-archive producer_plugin chain_plugin
PRIVATE wallet_api_plugin PRIVATE -Wl,--whole-archive wallet_api_plugin -Wl,--no-whole-archive
PRIVATE net_plugin net_api_plugin txn_test_gen_plugin PRIVATE net_plugin net_api_plugin -Wl,--whole-archive txn_test_gen_plugin -Wl,--no-whole-archive
PRIVATE http_plugin faucet_testnet_plugin PRIVATE http_plugin -Wl,--whole-archive faucet_testnet_plugin -Wl,--no-whole-archive
PRIVATE eosio_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ) PRIVATE eosio_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} )
install( TARGETS install( TARGETS
......
...@@ -4,17 +4,11 @@ ...@@ -4,17 +4,11 @@
*/ */
#include <appbase/application.hpp> #include <appbase/application.hpp>
#include <eosio/producer_plugin/producer_plugin.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp> #include <eosio/chain_plugin/chain_plugin.hpp>
#include <eosio/http_plugin/http_plugin.hpp> #include <eosio/http_plugin/http_plugin.hpp>
#include <eosio/chain_api_plugin/chain_api_plugin.hpp>
#include <eos/net_plugin/net_plugin.hpp> #include <eos/net_plugin/net_plugin.hpp>
#include <eos/net_api_plugin/net_api_plugin.hpp>
//#include <eosio/account_history_plugin/account_history_plugin.hpp> //#include <eosio/account_history_plugin/account_history_plugin.hpp>
//#include <eosio/account_history_api_plugin/account_history_api_plugin.hpp> //#include <eosio/account_history_api_plugin/account_history_api_plugin.hpp>
#include <eosio/wallet_api_plugin/wallet_api_plugin.hpp>
#include <eosio/txn_test_gen_plugin/txn_test_gen_plugin.hpp>
#include <eosio/faucet_testnet_plugin/faucet_testnet_plugin.hpp>
#include <fc/log/logger_config.hpp> #include <fc/log/logger_config.hpp>
#include <fc/log/appender.hpp> #include <fc/log/appender.hpp>
...@@ -44,14 +38,7 @@ int main(int argc, char** argv) ...@@ -44,14 +38,7 @@ int main(int argc, char** argv)
{ {
try { try {
app().set_version(eosio::eosiod::config::version); app().set_version(eosio::eosiod::config::version);
app().register_plugin<chain_api_plugin>();
app().register_plugin<producer_plugin>();
// app().register_plugin<account_history_api_plugin>(); // app().register_plugin<account_history_api_plugin>();
app().register_plugin<net_plugin>();
app().register_plugin<net_api_plugin>();
app().register_plugin<txn_test_gen_plugin>();
app().register_plugin<wallet_api_plugin>();
app().register_plugin<faucet_testnet_plugin>();
if(!app().initialize<chain_plugin, http_plugin, net_plugin>(argc, argv)) if(!app().initialize<chain_plugin, http_plugin, net_plugin>(argc, argv))
return -1; return -1;
initialize_logging(); initialize_logging();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册