diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-12-17 11:25:15 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-12-17 11:28:49 +0000 |
commit | 55fa0479a0db599d81500e57e355124f1fb9c05e (patch) | |
tree | d394bf9b6ad9f8d8320cc3a34e860c7af5bc671c /src/rpc/core_rpc_server.cpp | |
parent | Merge pull request #1459 (diff) | |
download | monero-55fa0479a0db599d81500e57e355124f1fb9c05e.tar.xz |
rpc: new function and RPC to get alternative chain info
Diffstat (limited to 'src/rpc/core_rpc_server.cpp')
-rw-r--r-- | src/rpc/core_rpc_server.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp index 5bf500733..c2ff63fc7 100644 --- a/src/rpc/core_rpc_server.cpp +++ b/src/rpc/core_rpc_server.cpp @@ -1337,6 +1337,24 @@ namespace cryptonote return true; } //------------------------------------------------------------------------------------------------------------------------------ + bool core_rpc_server::on_get_alternate_chains(const COMMAND_RPC_GET_ALTERNATE_CHAINS::request& req, COMMAND_RPC_GET_ALTERNATE_CHAINS::response& res, epee::json_rpc::error& error_resp) + { + try + { + std::list<std::pair<Blockchain::block_extended_info, uint64_t>> chains = m_core.get_blockchain_storage().get_alternative_chains(); + for (const auto &i: chains) + { + res.chains.push_back(COMMAND_RPC_GET_ALTERNATE_CHAINS::chain_info{epee::string_tools::pod_to_hex(get_block_hash(i.first.bl)), i.first.height, i.second, i.first.cumulative_difficulty}); + } + res.status = CORE_RPC_STATUS_OK; + } + catch (...) + { + res.status = "Error retrieving alternate chains"; + } + return true; + } + //------------------------------------------------------------------------------------------------------------------------------ bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res) { // TODO |