Print service node winner, cdifficulty and fix block_weight (#870)

This commit is contained in:
Doyle 2019-10-08 14:25:57 +11:00 committed by GitHub
parent 9872043fbb
commit 413d33a524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 18 deletions

View file

@ -135,20 +135,23 @@ namespace {
void print_block_header(cryptonote::block_header_response const & header)
{
tools::success_msg_writer()
<< "timestamp: " << boost::lexical_cast<std::string>(header.timestamp) << " (" << tools::get_human_readable_timestamp(header.timestamp) << ")" << std::endl
<< "previous hash: " << header.prev_hash << std::endl
<< "nonce: " << boost::lexical_cast<std::string>(header.nonce) << std::endl
<< "is orphan: " << header.orphan_status << std::endl
<< "height: " << boost::lexical_cast<std::string>(header.height) << std::endl
<< "depth: " << boost::lexical_cast<std::string>(header.depth) << std::endl
<< "hash: " << header.hash << std::endl
<< "difficulty: " << boost::lexical_cast<std::string>(header.difficulty) << std::endl
<< "POW hash: " << header.pow_hash << std::endl
<< "block size: " << header.block_size << std::endl
<< "block weight: " << header.block_weight << std::endl
<< "long term weight: " << header.long_term_weight << std::endl
<< "num txes: " << header.num_txes << std::endl
<< "reward: " << cryptonote::print_money(header.reward);
<< "timestamp: " << boost::lexical_cast<std::string>(header.timestamp) << " (" << tools::get_human_readable_timestamp(header.timestamp) << ")" << "\n"
<< "previous hash: " << header.prev_hash << "\n"
<< "nonce: " << boost::lexical_cast<std::string>(header.nonce) << "\n"
<< "is orphan: " << header.orphan_status << "\n"
<< "height: " << boost::lexical_cast<std::string>(header.height) << "\n"
<< "depth: " << boost::lexical_cast<std::string>(header.depth) << "\n"
<< "hash: " << header.hash << "\n"
<< "difficulty: " << boost::lexical_cast<std::string>(header.difficulty) << "\n"
<< "cumulative_difficulty: " << boost::lexical_cast<std::string>(header.cumulative_difficulty) << "\n"
<< "POW hash: " << header.pow_hash << "\n"
<< "block size: " << header.block_size << "\n"
<< "block weight: " << header.block_weight << "\n"
<< "long term weight: " << header.long_term_weight << "\n"
<< "num txes: " << header.num_txes << "\n"
<< "reward: " << cryptonote::print_money(header.reward) << "\n"
<< "miner reward: " << cryptonote::print_money(header.miner_reward) << "\n"
<< "service node winner: " << header.service_node_winner << std::endl;
}
std::string get_human_time_ago(time_t t, time_t now)

View file

@ -1472,7 +1472,8 @@ namespace cryptonote
response.depth = m_core.get_current_blockchain_height() - height - 1;
response.hash = string_tools::pod_to_hex(hash);
response.difficulty = m_core.get_blockchain_storage().block_difficulty(height);
response.cumulative_difficulty = response.block_weight = m_core.get_blockchain_storage().get_db().get_block_cumulative_difficulty(height);
response.cumulative_difficulty = m_core.get_blockchain_storage().get_db().get_block_cumulative_difficulty(height);
response.block_weight = m_core.get_blockchain_storage().get_db().get_block_weight(height);
response.reward = get_block_reward(blk);
response.miner_reward = blk.miner_tx.vout[0].amount;
response.block_size = response.block_weight = m_core.get_blockchain_storage().get_db().get_block_weight(height);
@ -1480,6 +1481,7 @@ namespace cryptonote
response.pow_hash = fill_pow_hash ? string_tools::pod_to_hex(get_block_longhash(&(m_core.get_blockchain_storage()), blk, height, 0)) : "";
response.long_term_weight = m_core.get_blockchain_storage().get_db().get_block_long_term_weight(height);
response.miner_tx_hash = string_tools::pod_to_hex(cryptonote::get_transaction_hash(blk.miner_tx));
response.service_node_winner = string_tools::pod_to_hex(cryptonote::get_service_node_winner_from_tx_extra(blk.miner_tx.extra));
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
@ -1762,7 +1764,6 @@ namespace cryptonote
error_resp.message = "Internal error: can't produce valid response.";
return false;
}
res.miner_tx_hash = epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(blk.miner_tx));
for (size_t n = 0; n < blk.tx_hashes.size(); ++n)
{
res.tx_hashes.push_back(epee::string_tools::pod_to_hex(blk.tx_hashes[n]));

View file

@ -92,7 +92,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 3
#define CORE_RPC_VERSION_MINOR 0
#define CORE_RPC_VERSION_MINOR 1
#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)
@ -1147,7 +1147,8 @@ namespace cryptonote
uint64_t num_txes; // Number of transactions in the block, not counting the coinbase tx.
std::string pow_hash; // The hash of the block's proof of work.
uint64_t long_term_weight; // Long term weight of the block.
std::string miner_tx_hash;
std::string miner_tx_hash; // The TX hash of the miner transaction
std::string service_node_winner; // Service node that received a reward for this block
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(major_version)
@ -1169,6 +1170,7 @@ namespace cryptonote
KV_SERIALIZE(pow_hash)
KV_SERIALIZE_OPT(long_term_weight, (uint64_t)0)
KV_SERIALIZE(miner_tx_hash)
KV_SERIALIZE(service_node_winner)
END_KV_SERIALIZE_MAP()
};