forked from lthn/blockchain
added another command for getting difficulty numbers
This commit is contained in:
parent
bdd76b28c8
commit
dca5aae9cb
3 changed files with 61 additions and 1 deletions
|
|
@ -2665,6 +2665,46 @@ void blockchain_storage::print_db_cache_perfeormance_data() const
|
|||
);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
void blockchain_storage::get_last_n_x_blocks(uint64_t n, bool pos_blocks, std::list<std::shared_ptr<const block_extended_info>>& blocks) const
|
||||
{
|
||||
uint64_t count = 0;
|
||||
bool looking_for_a_pos = true;
|
||||
for (uint64_t i = m_db_blocks.size() - 1; i != 0; --i)
|
||||
{
|
||||
auto block_ptr = m_db_blocks[i];
|
||||
if (is_pos_block(block_ptr->bl) == pos_blocks)
|
||||
{
|
||||
blocks.push_back(block_ptr);
|
||||
++count;
|
||||
if (count >= n)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
void blockchain_storage::print_last_n_difficulty_numbers(uint64_t n) const
|
||||
{
|
||||
|
||||
std::stringstream ss;
|
||||
std::list<std::shared_ptr<const block_extended_info>> pos_blocks;
|
||||
std::list<std::shared_ptr<const block_extended_info>> pow_blocks;
|
||||
|
||||
get_last_n_x_blocks(n, true, pos_blocks);
|
||||
get_last_n_x_blocks(n, false, pow_blocks);
|
||||
ss << "PoS blocks difficulty:" << ENDL;
|
||||
for (auto& bl_ptr : pos_blocks)
|
||||
{
|
||||
ss << bl_ptr->cumulative_diff_precise << ENDL;
|
||||
}
|
||||
|
||||
ss << "PoW blocks difficulty:" << ENDL;
|
||||
for (auto& bl_ptr : pow_blocks)
|
||||
{
|
||||
ss << bl_ptr->cumulative_diff_precise << ENDL;
|
||||
}
|
||||
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
void blockchain_storage::print_blockchain_outs_stat() const
|
||||
{
|
||||
LOG_ERROR("NOT IMPLEMENTED YET");
|
||||
|
|
|
|||
|
|
@ -430,6 +430,7 @@ namespace currency
|
|||
void print_blockchain_outs(const std::string& file) const;
|
||||
void print_blockchain_outs_stat() const;
|
||||
void print_db_cache_perfeormance_data() const;
|
||||
void print_last_n_difficulty_numbers(uint64_t n) const;
|
||||
bool calc_tx_cummulative_blob(const block& bl)const;
|
||||
bool get_outs_index_stat(outs_index_stat& outs_stat)const;
|
||||
bool print_lookup_key_image(const crypto::key_image& ki) const;
|
||||
|
|
@ -561,7 +562,7 @@ namespace currency
|
|||
bool validate_alt_block_txs(const block& b, const crypto::hash& id, std::set<crypto::key_image>& collected_keyimages, alt_block_extended_info& abei, const alt_chain_type& alt_chain, uint64_t split_height, uint64_t& ki_lookup_time_total) const;
|
||||
bool update_alt_out_indexes_for_tx_in_block(const transaction& tx, alt_block_extended_info& abei)const;
|
||||
bool get_transaction_from_pool_or_db(const crypto::hash& tx_id, std::shared_ptr<transaction>& tx_ptr, uint64_t min_allowed_block_height = 0) const;
|
||||
|
||||
void get_last_n_x_blocks(uint64_t n, bool pos_blocks, std::list<std::shared_ptr<const block_extended_info>>& blocks) const;
|
||||
bool prevalidate_miner_transaction(const block& b, uint64_t height, bool pos)const;
|
||||
bool rollback_blockchain_switching(std::list<block>& original_chain, size_t rollback_height);
|
||||
bool add_transaction_from_block(const transaction& tx, const crypto::hash& tx_id, const crypto::hash& bl_id, uint64_t bl_height, uint64_t timestamp);
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public:
|
|||
m_cmd_binder.set_handler("print_block_from_hex_blob", boost::bind(&daemon_commands_handler::print_block_from_hex_blob, this, _1), "Unserialize block from hex binary data to json-like representation");
|
||||
m_cmd_binder.set_handler("print_tx_from_hex_blob", boost::bind(&daemon_commands_handler::print_tx_from_hex_blob, this, _1), "Unserialize transaction from hex binary data to json-like representation");
|
||||
m_cmd_binder.set_handler("print_tx_outputs_usage", boost::bind(&daemon_commands_handler::print_tx_outputs_usage, this, _1), "Analyse if tx outputs for involved in subsequent transactions");
|
||||
m_cmd_binder.set_handler("print_difficulties_of_last_n_blocks", boost::bind(&daemon_commands_handler::print_difficulties_of_last_n_blocks, this, _1), "Print difficulties of last n blocks");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -696,8 +697,26 @@ private:
|
|||
m_srv.get_payload_object().get_core().get_blockchain_storage().print_tx_outputs_lookup(tx_hash);
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_difficulties_of_last_n_blocks(const std::vector<std::string>& args)
|
||||
{
|
||||
if (args.empty())
|
||||
{
|
||||
std::cout << "expected: n - number of blocks to read" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string& amount = args.front();
|
||||
uint64_t n = 0;
|
||||
if (!epee::string_tools::get_xtype_from_string(n, amount))
|
||||
{
|
||||
std::cout << "unable to convert to number '" << amount << "'" << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_srv.get_payload_object().get_core().get_blockchain_storage().print_last_n_difficulty_numbers(n);
|
||||
return true;
|
||||
}
|
||||
//--------------------------------------------------------------------------------
|
||||
bool print_pool(const std::vector<std::string>& args)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue