Skip to content

Commit

Permalink
Add database_api.get_version and return runtime chain_id steemit#2849
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed Aug 28, 2018
1 parent c6b865b commit 5d92683
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
18 changes: 17 additions & 1 deletion libraries/plugins/apis/database_api/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <steem/protocol/exceptions.hpp>
#include <steem/protocol/transaction_util.hpp>

#include <steem/utilities/git_revision.hpp>

#include <fc/git_revision.hpp>

namespace steem { namespace plugins { namespace database_api {

class database_api_impl
Expand All @@ -18,6 +22,7 @@ class database_api_impl
DECLARE_API_IMPL
(
(get_config)
(get_version)
(get_dynamic_global_properties)
(get_witness_schedule)
(get_hardfork_properties)
Expand Down Expand Up @@ -119,6 +124,17 @@ DEFINE_API_IMPL( database_api_impl, get_config )
return steem::protocol::get_config();
}

DEFINE_API_IMPL( database_api_impl, get_version )
{
return get_version_return
(
fc::string( STEEM_BLOCKCHAIN_VERSION ),
fc::string( steem::utilities::git_revision_sha ),
fc::string( fc::git_revision_sha ),
_db.get_chain_id()
);
}

DEFINE_API_IMPL( database_api_impl, get_dynamic_global_properties )
{
return _db.get_dynamic_global_properties();
Expand Down Expand Up @@ -1439,7 +1455,7 @@ DEFINE_API_IMPL( database_api_impl, get_smt_next_identifier )
}
#endif

DEFINE_LOCKLESS_APIS( database_api, (get_config) )
DEFINE_LOCKLESS_APIS( database_api, (get_config)(get_version) )

DEFINE_READ_APIS( database_api,
(get_dynamic_global_properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class database_api
*/
(get_config)

/**
* @brief Return version information and chain_id of running node
*/
(get_version)

/**
* @brief Retrieve the current @ref dynamic_global_property_object
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@ enum sort_order_type
typedef void_type get_config_args;
typedef fc::variant_object get_config_return;

/* get_version */
typedef void_type get_version_args;
struct get_version_return
{
get_version_return() {}
get_version_return( fc::string bc_v, fc::string s_v, fc::string fc_v, chain_id_type c_id )
:blockchain_version( bc_v ), steem_revision( s_v ), fc_revision( fc_v ), chain_id( c_id ) {}

fc::string blockchain_version;
fc::string steem_revision;
fc::string fc_revision;
chain_id_type chain_id;
};


/* Singletons */

Expand Down Expand Up @@ -567,6 +581,9 @@ struct get_smt_next_identifier_return

} } } // steem::database_api

FC_REFLECT( steem::plugins::database_api::get_version_return,
(blockchain_version)(steem_revision)(fc_revision)(chain_id) )

FC_REFLECT_ENUM( steem::plugins::database_api::sort_order_type,
(by_name)
(by_proxy)
Expand Down

0 comments on commit 5d92683

Please sign in to comment.