mirror of
https://github.com/monero-project/monero.git
synced 2025-10-13 06:30:38 -04:00
alt_chain_info can now give more info about a particular alt chain
This commit is contained in:
parent
25e7a7d96f
commit
50af3579ee
8 changed files with 57 additions and 19 deletions
|
@ -1774,10 +1774,22 @@ namespace cryptonote
|
|||
PERF_TIMER(on_get_alternate_chains);
|
||||
try
|
||||
{
|
||||
std::list<std::pair<Blockchain::block_extended_info, uint64_t>> chains = m_core.get_blockchain_storage().get_alternative_chains();
|
||||
std::list<std::pair<Blockchain::block_extended_info, std::vector<crypto::hash>>> 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.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.size(), i.first.cumulative_difficulty, {}, std::string()});
|
||||
res.chains.back().block_hashes.reserve(i.second.size());
|
||||
for (const crypto::hash &block_id: i.second)
|
||||
res.chains.back().block_hashes.push_back(epee::string_tools::pod_to_hex(block_id));
|
||||
if (i.first.height < i.second.size())
|
||||
{
|
||||
res.status = "Error finding alternate chain attachment point";
|
||||
return true;
|
||||
}
|
||||
cryptonote::block main_chain_parent_block;
|
||||
try { main_chain_parent_block = m_core.get_blockchain_storage().get_db().get_block_from_height(i.first.height - i.second.size()); }
|
||||
catch (const std::exception &e) { res.status = "Error finding alternate chain attachment point"; return true; }
|
||||
res.chains.back().main_chain_parent_block = epee::string_tools::pod_to_hex(get_block_hash(main_chain_parent_block));
|
||||
}
|
||||
res.status = CORE_RPC_STATUS_OK;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace cryptonote
|
|||
// advance which version they will stop working with
|
||||
// Don't go over 32767 for any of these
|
||||
#define CORE_RPC_VERSION_MAJOR 1
|
||||
#define CORE_RPC_VERSION_MINOR 20
|
||||
#define CORE_RPC_VERSION_MINOR 21
|
||||
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
||||
|
||||
|
@ -2086,12 +2086,16 @@ namespace cryptonote
|
|||
uint64_t height;
|
||||
uint64_t length;
|
||||
uint64_t difficulty;
|
||||
std::vector<std::string> block_hashes;
|
||||
std::string main_chain_parent_block;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(block_hash)
|
||||
KV_SERIALIZE(height)
|
||||
KV_SERIALIZE(length)
|
||||
KV_SERIALIZE(difficulty)
|
||||
KV_SERIALIZE(block_hashes)
|
||||
KV_SERIALIZE(main_chain_parent_block)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue