提交 1fd2a4cc 编写于 作者: K Kevin Heifner

Fix history plugin not enabled message

上级 e58b62c4
file( GLOB HEADERS "include/eosio/account_history_api_plugin/*.hpp" )
add_library( account_history_api_plugin
account_history_api_plugin.cpp
${HEADERS} )
target_link_libraries( account_history_api_plugin account_history_plugin chain_plugin http_plugin appbase )
target_include_directories( account_history_api_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#include <eosio/account_history_api_plugin/account_history_api_plugin.hpp>
#include <eosio/chain/chain_controller.hpp>
#include <eosio/chain/exceptions.hpp>
#include <fc/io/json.hpp>
namespace eosio {
using namespace eosio;
static appbase::abstract_plugin& _account_history_api_plugin = app().register_plugin<account_history_api_plugin>();
account_history_api_plugin::account_history_api_plugin(){}
account_history_api_plugin::~account_history_api_plugin(){}
void account_history_api_plugin::set_program_options(options_description&, options_description&) {}
void account_history_api_plugin::plugin_initialize(const variables_map&) {}
#define CALL(api_name, api_handle, api_namespace, call_name) \
{std::string("/v1/" #api_name "/" #call_name), \
[this, api_handle](string, string body, url_response_callback cb) mutable { \
try { \
if (body.empty()) body = "{}"; \
auto result = api_handle.call_name(fc::json::from_string(body).as<api_namespace::call_name ## _params>()); \
cb(200, fc::json::to_string(result)); \
} catch (...) { \
http_plugin::handle_exception(#api_name, #call_name, body, cb); \
} \
}}
#define CHAIN_RO_CALL(call_name) CALL(account_history, ro_api, account_history_apis::read_only, call_name)
#define CHAIN_RW_CALL(call_name) CALL(account_history, rw_api, account_history_apis::read_write, call_name)
void account_history_api_plugin::plugin_startup() {
ilog( "starting account_history_api_plugin" );
auto ro_api = app().get_plugin<account_history_plugin>().get_read_only_api();
auto rw_api = app().get_plugin<account_history_plugin>().get_read_write_api();
app().get_plugin<http_plugin>().add_api({
CHAIN_RO_CALL(get_transaction),
CHAIN_RO_CALL(get_transactions),
CHAIN_RO_CALL(get_key_accounts),
CHAIN_RO_CALL(get_controlled_accounts)
});
}
void account_history_api_plugin::plugin_shutdown() {}
}
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <eosio/account_history_plugin/account_history_plugin.hpp>
#include <eosio/chain_plugin/chain_plugin.hpp>
#include <eosio/http_plugin/http_plugin.hpp>
#include <appbase/application.hpp>
namespace eosio {
using namespace appbase;
class account_history_api_plugin : public plugin<account_history_api_plugin> {
public:
APPBASE_PLUGIN_REQUIRES((account_history_plugin)(chain_plugin)(http_plugin))
account_history_api_plugin();
virtual ~account_history_api_plugin();
virtual void set_program_options(options_description&, options_description&) override;
void plugin_initialize(const variables_map&);
void plugin_startup();
void plugin_shutdown();
private:
};
}
file(GLOB HEADERS "include/eosio/account_history_plugin/*.hpp")
add_library( account_history_plugin
account_history_plugin.cpp
${HEADERS} )
target_link_libraries( account_history_plugin chain_plugin eosio_chain appbase )
target_include_directories( account_history_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <chainbase/chainbase.hpp>
#include <eosio/chain/types.hpp>
namespace std {
template<>
struct hash<eosio::chain::account_name>
{
size_t operator()( const eosio::chain::account_name& name )const
{
return (uint64_t)name;
}
};
}
namespace eosio {
using chain::account_name;
using chain::shared_vector;
using chain::transaction_id_type;
using namespace boost::multi_index;
class account_transaction_history_object : public chainbase::object<chain::account_transaction_history_object_type, account_transaction_history_object> {
OBJECT_CTOR(account_transaction_history_object)
id_type id;
account_name name;
transaction_id_type transaction_id;
};
struct by_id;
struct by_account_name;
struct by_account_name_trx_id;
using account_transaction_history_multi_index = chainbase::shared_multi_index_container<
account_transaction_history_object,
indexed_by<
ordered_unique<tag<by_id>, BOOST_MULTI_INDEX_MEMBER(account_transaction_history_object, account_transaction_history_object::id_type, id)>,
ordered_unique<tag<by_account_name>,
composite_key< account_transaction_history_object,
member<account_transaction_history_object, account_name, &account_transaction_history_object::name>,
member<account_transaction_history_object, transaction_id_type, &account_transaction_history_object::transaction_id>
>
>
>
>;
typedef chainbase::generic_index<account_transaction_history_multi_index> account_transaction_history_index;
}
CHAINBASE_SET_INDEX_TYPE( eosio::account_transaction_history_object, eosio::account_transaction_history_multi_index )
FC_REFLECT( eosio::account_transaction_history_object, (name)(transaction_id) )
/**
* @file
* @copyright defined in eos/LICENSE.txt
*/
#pragma once
#include <chainbase/chainbase.hpp>
#include <eosio/chain/transaction.hpp>
namespace eosio {
using chain::block_id_type;
using chain::transaction_id_type;
using chain::transaction_receipt;
using namespace boost::multi_index;
class transaction_history_object : public chainbase::object<chain::transaction_history_object_type, transaction_history_object> {
OBJECT_CTOR(transaction_history_object)
id_type id;
block_id_type block_id;
transaction_id_type transaction_id;
transaction_receipt::status_enum transaction_status;
};
struct by_id;
struct by_trx_id;
using transaction_history_multi_index = chainbase::shared_multi_index_container<
transaction_history_object,
indexed_by<
ordered_unique<tag<by_id>, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_history_object::id_type, id)>,
ordered_unique<tag<by_trx_id>, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_id_type, transaction_id)>
>
>;
typedef chainbase::generic_index<transaction_history_multi_index> transaction_history_index;
}
CHAINBASE_SET_INDEX_TYPE( eosio::transaction_history_object, eosio::transaction_history_multi_index )
FC_REFLECT( eosio::transaction_history_object, (block_id)(transaction_id)(transaction_status) )
......@@ -255,7 +255,7 @@ namespace eosio { namespace client { namespace http {
throw chain::missing_chain_api_plugin_exception(FC_LOG_MESSAGE(error, "Chain API plugin is not enabled"));
} else if (url.path.compare(0, wallet_func_base.size(), wallet_func_base) == 0) {
throw chain::missing_wallet_api_plugin_exception(FC_LOG_MESSAGE(error, "Wallet is not available"));
} else if (url.path.compare(0, account_history_func_base.size(), account_history_func_base) == 0) {
} else if (url.path.compare(0, history_func_base.size(), history_func_base) == 0) {
throw chain::missing_history_api_plugin_exception(FC_LOG_MESSAGE(error, "History API plugin is not enabled"));
} else if (url.path.compare(0, net_func_base.size(), net_func_base) == 0) {
throw chain::missing_net_api_plugin_exception(FC_LOG_MESSAGE(error, "Net API plugin is not enabled"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册