mirror of
https://github.com/monero-project/monero.git
synced 2024-12-13 11:56:31 +02:00
daemon: sort alt chains by height
This commit is contained in:
parent
c0bc6d96cd
commit
0605406714
@ -4798,9 +4798,9 @@ std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> Blockchain:: get_ou
|
|||||||
return m_db->get_output_histogram(amounts, unlocked, recent_cutoff, min_count);
|
return m_db->get_output_histogram(amounts, unlocked, recent_cutoff, min_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::pair<Blockchain::block_extended_info,std::vector<crypto::hash>>> Blockchain::get_alternative_chains() const
|
std::vector<std::pair<Blockchain::block_extended_info,std::vector<crypto::hash>>> Blockchain::get_alternative_chains() const
|
||||||
{
|
{
|
||||||
std::list<std::pair<Blockchain::block_extended_info,std::vector<crypto::hash>>> chains;
|
std::vector<std::pair<Blockchain::block_extended_info,std::vector<crypto::hash>>> chains;
|
||||||
|
|
||||||
for (const auto &i: m_alternative_chains)
|
for (const auto &i: m_alternative_chains)
|
||||||
{
|
{
|
||||||
|
@ -961,9 +961,9 @@ namespace cryptonote
|
|||||||
/**
|
/**
|
||||||
* @brief returns a set of known alternate chains
|
* @brief returns a set of known alternate chains
|
||||||
*
|
*
|
||||||
* @return a list of chains
|
* @return a vector of chains
|
||||||
*/
|
*/
|
||||||
std::list<std::pair<block_extended_info,std::vector<crypto::hash>>> get_alternative_chains() const;
|
std::vector<std::pair<block_extended_info,std::vector<crypto::hash>>> get_alternative_chains() const;
|
||||||
|
|
||||||
void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata &blob, const txpool_tx_meta_t &meta);
|
void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata &blob, const txpool_tx_meta_t &meta);
|
||||||
void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t &meta);
|
void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t &meta);
|
||||||
|
@ -1861,7 +1861,9 @@ bool t_rpc_command_executor::alt_chain_info(const std::string &tip)
|
|||||||
if (tip.empty())
|
if (tip.empty())
|
||||||
{
|
{
|
||||||
tools::msg_writer() << boost::lexical_cast<std::string>(res.chains.size()) << " alternate chains found:";
|
tools::msg_writer() << boost::lexical_cast<std::string>(res.chains.size()) << " alternate chains found:";
|
||||||
for (const auto &chain: res.chains)
|
auto chains = res.chains;
|
||||||
|
std::sort(chains.begin(), chains.end(), [](const cryptonote::COMMAND_RPC_GET_ALTERNATE_CHAINS::chain_info &info0, cryptonote::COMMAND_RPC_GET_ALTERNATE_CHAINS::chain_info &info1){ return info0.height < info1.height; });
|
||||||
|
for (const auto &chain: chains)
|
||||||
{
|
{
|
||||||
uint64_t start_height = (chain.height - chain.length + 1);
|
uint64_t start_height = (chain.height - chain.length + 1);
|
||||||
tools::msg_writer() << chain.length << " blocks long, from height " << start_height << " (" << (ires.height - start_height - 1)
|
tools::msg_writer() << chain.length << " blocks long, from height " << start_height << " (" << (ires.height - start_height - 1)
|
||||||
|
@ -1991,7 +1991,7 @@ namespace cryptonote
|
|||||||
PERF_TIMER(on_get_alternate_chains);
|
PERF_TIMER(on_get_alternate_chains);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::list<std::pair<Blockchain::block_extended_info, std::vector<crypto::hash>>> chains = m_core.get_blockchain_storage().get_alternative_chains();
|
std::vector<std::pair<Blockchain::block_extended_info, std::vector<crypto::hash>>> chains = m_core.get_blockchain_storage().get_alternative_chains();
|
||||||
for (const auto &i: chains)
|
for (const auto &i: chains)
|
||||||
{
|
{
|
||||||
difficulty_type wdiff = i.first.cumulative_difficulty;
|
difficulty_type wdiff = i.first.cumulative_difficulty;
|
||||||
|
@ -2070,7 +2070,7 @@ namespace cryptonote
|
|||||||
struct response_t
|
struct response_t
|
||||||
{
|
{
|
||||||
std::string status;
|
std::string status;
|
||||||
std::list<chain_info> chains;
|
std::vector<chain_info> chains;
|
||||||
|
|
||||||
BEGIN_KV_SERIALIZE_MAP()
|
BEGIN_KV_SERIALIZE_MAP()
|
||||||
KV_SERIALIZE(status)
|
KV_SERIALIZE(status)
|
||||||
|
Loading…
Reference in New Issue
Block a user