rpc: new function and RPC to get alternative chain info

This commit is contained in:
moneromooo-monero 2016-12-17 11:25:15 +00:00
parent 29735c8f8f
commit 55fa0479a0
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
10 changed files with 147 additions and 0 deletions

View file

@ -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