Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print service node winner, cdifficulty and fix block_weight #870

Merged
merged 1 commit into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/daemon/rpc_command_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 That's a whole lot of superfluous flushing.

}

std::string get_human_time_ago(time_t t, time_t now)
Expand Down
5 changes: 3 additions & 2 deletions src/rpc/core_rpc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1472,14 +1472,16 @@ 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);
response.num_txes = blk.tx_hashes.size();
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;
}
//------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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]));
Expand Down
6 changes: 4 additions & 2 deletions src/rpc/core_rpc_server_commands_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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()
};

Expand Down