Merge pull request #462 from wackou/api-339
Api calls for #339: needed api calls (mostly network) for supporting bts_tools
This commit is contained in:
commit
0b4675354a
4 changed files with 94 additions and 7 deletions
|
|
@ -141,11 +141,11 @@ namespace graphene { namespace app {
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::variant network_node_api::get_info() const
|
fc::variant_object network_node_api::get_info() const
|
||||||
{
|
{
|
||||||
fc::mutable_variant_object result = _app.p2p_node()->network_get_info();
|
fc::mutable_variant_object result = _app.p2p_node()->network_get_info();
|
||||||
result["connection_count"] = _app.p2p_node()->get_connection_count();
|
result["connection_count"] = _app.p2p_node()->get_connection_count();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void network_node_api::add_node(const fc::ip::endpoint& ep)
|
void network_node_api::add_node(const fc::ip::endpoint& ep)
|
||||||
|
|
@ -155,7 +155,22 @@ namespace graphene { namespace app {
|
||||||
|
|
||||||
std::vector<net::peer_status> network_node_api::get_connected_peers() const
|
std::vector<net::peer_status> network_node_api::get_connected_peers() const
|
||||||
{
|
{
|
||||||
return _app.p2p_node()->get_connected_peers();
|
return _app.p2p_node()->get_connected_peers();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<net::potential_peer_record> network_node_api::get_potential_peers() const
|
||||||
|
{
|
||||||
|
return _app.p2p_node()->get_potential_peers();
|
||||||
|
}
|
||||||
|
|
||||||
|
fc::variant_object network_node_api::get_advanced_node_parameters() const
|
||||||
|
{
|
||||||
|
return _app.p2p_node()->get_advanced_node_parameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
void network_node_api::set_advanced_node_parameters(const fc::variant_object& params)
|
||||||
|
{
|
||||||
|
return _app.p2p_node()->set_advanced_node_parameters(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::api<network_broadcast_api> login_api::network_broadcast()const
|
fc::api<network_broadcast_api> login_api::network_broadcast()const
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ namespace graphene { namespace app {
|
||||||
/**
|
/**
|
||||||
* @brief Return general network information, such as p2p port
|
* @brief Return general network information, such as p2p port
|
||||||
*/
|
*/
|
||||||
fc::variant get_info() const;
|
fc::variant_object get_info() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief add_node Connect to a new peer
|
* @brief add_node Connect to a new peer
|
||||||
|
|
@ -149,9 +149,27 @@ namespace graphene { namespace app {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get status of all current connections to peers
|
* @brief Get status of all current connections to peers
|
||||||
*/
|
*/
|
||||||
std::vector<net::peer_status> get_connected_peers() const;
|
std::vector<net::peer_status> get_connected_peers() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get advanced node parameters, such as desired and max
|
||||||
|
* number of connections
|
||||||
|
*/
|
||||||
|
fc::variant_object get_advanced_node_parameters() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set advanced node parameters, such as desired and max
|
||||||
|
* number of connections
|
||||||
|
* @param params a JSON object containing the name/value pairs for the parameters to set
|
||||||
|
*/
|
||||||
|
void set_advanced_node_parameters(const fc::variant_object& params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return list of potential peers
|
||||||
|
*/
|
||||||
|
std::vector<net::potential_peer_record> get_potential_peers() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
application& _app;
|
application& _app;
|
||||||
};
|
};
|
||||||
|
|
@ -217,6 +235,9 @@ FC_API(graphene::app::network_node_api,
|
||||||
(get_info)
|
(get_info)
|
||||||
(add_node)
|
(add_node)
|
||||||
(get_connected_peers)
|
(get_connected_peers)
|
||||||
|
(get_potential_peers)
|
||||||
|
(get_advanced_node_parameters)
|
||||||
|
(set_advanced_node_parameters)
|
||||||
)
|
)
|
||||||
FC_API(graphene::app::login_api,
|
FC_API(graphene::app::login_api,
|
||||||
(login)
|
(login)
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,10 @@ class wallet_api
|
||||||
fc::ecc::private_key derive_private_key(const std::string& prefix_string, int sequence_number) const;
|
fc::ecc::private_key derive_private_key(const std::string& prefix_string, int sequence_number) const;
|
||||||
|
|
||||||
variant info();
|
variant info();
|
||||||
|
/** Returns info such as client version, git version of graphene/fc, version of boost, openssl.
|
||||||
|
* @returns compile time info and client and dependencies versions
|
||||||
|
*/
|
||||||
|
variant_object about() const;
|
||||||
optional<signed_block_with_info> get_block( uint32_t num );
|
optional<signed_block_with_info> get_block( uint32_t num );
|
||||||
/** Returns the number of accounts registered on the blockchain
|
/** Returns the number of accounts registered on the blockchain
|
||||||
* @returns the number of registered accounts
|
* @returns the number of registered accounts
|
||||||
|
|
@ -1470,6 +1474,7 @@ FC_API( graphene::wallet::wallet_api,
|
||||||
(help)
|
(help)
|
||||||
(gethelp)
|
(gethelp)
|
||||||
(info)
|
(info)
|
||||||
|
(about)
|
||||||
(begin_builder_transaction)
|
(begin_builder_transaction)
|
||||||
(add_operation_to_builder_transaction)
|
(add_operation_to_builder_transaction)
|
||||||
(replace_operation_in_builder_transaction)
|
(replace_operation_in_builder_transaction)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
#include <boost/version.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
|
|
||||||
#include <boost/range/adaptor/map.hpp>
|
#include <boost/range/adaptor/map.hpp>
|
||||||
#include <boost/range/algorithm_ext/erase.hpp>
|
#include <boost/range/algorithm_ext/erase.hpp>
|
||||||
#include <boost/range/algorithm/unique.hpp>
|
#include <boost/range/algorithm/unique.hpp>
|
||||||
|
|
@ -41,6 +45,7 @@
|
||||||
#include <boost/multi_index/sequenced_index.hpp>
|
#include <boost/multi_index/sequenced_index.hpp>
|
||||||
#include <boost/multi_index/hashed_index.hpp>
|
#include <boost/multi_index/hashed_index.hpp>
|
||||||
|
|
||||||
|
#include <fc/git_revision.hpp>
|
||||||
#include <fc/io/fstream.hpp>
|
#include <fc/io/fstream.hpp>
|
||||||
#include <fc/io/json.hpp>
|
#include <fc/io/json.hpp>
|
||||||
#include <fc/io/stdio.hpp>
|
#include <fc/io/stdio.hpp>
|
||||||
|
|
@ -55,6 +60,7 @@
|
||||||
#include <graphene/app/api.hpp>
|
#include <graphene/app/api.hpp>
|
||||||
#include <graphene/chain/asset_object.hpp>
|
#include <graphene/chain/asset_object.hpp>
|
||||||
#include <graphene/chain/protocol/fee_schedule.hpp>
|
#include <graphene/chain/protocol/fee_schedule.hpp>
|
||||||
|
#include <graphene/utilities/git_revision.hpp>
|
||||||
#include <graphene/utilities/key_conversion.hpp>
|
#include <graphene/utilities/key_conversion.hpp>
|
||||||
#include <graphene/utilities/words.hpp>
|
#include <graphene/utilities/words.hpp>
|
||||||
#include <graphene/wallet/wallet.hpp>
|
#include <graphene/wallet/wallet.hpp>
|
||||||
|
|
@ -506,6 +512,41 @@ public:
|
||||||
result["active_committee_members"] = global_props.active_committee_members;
|
result["active_committee_members"] = global_props.active_committee_members;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variant_object about() const
|
||||||
|
{
|
||||||
|
string client_version( graphene::utilities::git_revision_description );
|
||||||
|
const size_t pos = client_version.find( '/' );
|
||||||
|
if( pos != string::npos && client_version.size() > pos )
|
||||||
|
client_version = client_version.substr( pos + 1 );
|
||||||
|
|
||||||
|
fc::mutable_variant_object result;
|
||||||
|
//result["blockchain_name"] = BLOCKCHAIN_NAME;
|
||||||
|
//result["blockchain_description"] = BTS_BLOCKCHAIN_DESCRIPTION;
|
||||||
|
result["client_version"] = client_version;
|
||||||
|
result["graphene_revision"] = graphene::utilities::git_revision_sha;
|
||||||
|
result["graphene_revision_age"] = fc::get_approximate_relative_time_string( fc::time_point_sec( graphene::utilities::git_revision_unix_timestamp ) );
|
||||||
|
result["fc_revision"] = fc::git_revision_sha;
|
||||||
|
result["fc_revision_age"] = fc::get_approximate_relative_time_string( fc::time_point_sec( fc::git_revision_unix_timestamp ) );
|
||||||
|
result["compile_date"] = "compiled on " __DATE__ " at " __TIME__;
|
||||||
|
result["boost_version"] = boost::replace_all_copy(std::string(BOOST_LIB_VERSION), "_", ".");
|
||||||
|
result["openssl_version"] = OPENSSL_VERSION_TEXT;
|
||||||
|
|
||||||
|
std::string bitness = boost::lexical_cast<std::string>(8 * sizeof(int*)) + "-bit";
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
std::string os = "osx";
|
||||||
|
#elif defined(__linux__)
|
||||||
|
std::string os = "linux";
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
std::string os = "win32";
|
||||||
|
#else
|
||||||
|
std::string os = "other";
|
||||||
|
#endif
|
||||||
|
result["build"] = os + " " + bitness;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
chain_property_object get_chain_properties() const
|
chain_property_object get_chain_properties() const
|
||||||
{
|
{
|
||||||
return _remote_db->get_chain_properties();
|
return _remote_db->get_chain_properties();
|
||||||
|
|
@ -2866,6 +2907,11 @@ variant wallet_api::info()
|
||||||
return my->info();
|
return my->info();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variant_object wallet_api::about() const
|
||||||
|
{
|
||||||
|
return my->about();
|
||||||
|
}
|
||||||
|
|
||||||
fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_string, int sequence_number) const
|
fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_string, int sequence_number) const
|
||||||
{
|
{
|
||||||
return detail::derive_private_key( prefix_string, sequence_number );
|
return detail::derive_private_key( prefix_string, sequence_number );
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue