mirror of
https://github.com/monero-project/monero.git
synced 2025-08-12 07:30:08 -04:00
Add expected total reward to RPC "getblocktemplate".
Only works from V5 fork onward - returns 0 before that block.
This commit is contained in:
parent
9ed496bbc5
commit
bff90264b8
10 changed files with 19 additions and 12 deletions
|
@ -1072,7 +1072,7 @@ uint64_t Blockchain::get_current_cumulative_blocksize_limit() const
|
|||
// in a lot of places. That flag is not referenced in any of the code
|
||||
// nor any of the makefiles, howeve. Need to look into whether or not it's
|
||||
// necessary at all.
|
||||
bool Blockchain::create_block_template(block& b, const account_public_address& miner_address, difficulty_type& diffic, uint64_t& height, const blobdata& ex_nonce)
|
||||
bool Blockchain::create_block_template(block& b, const account_public_address& miner_address, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce)
|
||||
{
|
||||
LOG_PRINT_L3("Blockchain::" << __func__);
|
||||
size_t median_size;
|
||||
|
@ -1096,7 +1096,7 @@ bool Blockchain::create_block_template(block& b, const account_public_address& m
|
|||
|
||||
size_t txs_size;
|
||||
uint64_t fee;
|
||||
if (!m_tx_pool.fill_block_template(b, median_size, already_generated_coins, txs_size, fee, m_hardfork->get_current_version()))
|
||||
if (!m_tx_pool.fill_block_template(b, median_size, already_generated_coins, txs_size, fee, expected_reward, m_hardfork->get_current_version()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -323,11 +323,12 @@ namespace cryptonote
|
|||
* @param miner_address address new coins for the block will go to
|
||||
* @param di return-by-reference tells the miner what the difficulty target is
|
||||
* @param height return-by-reference tells the miner what height it's mining against
|
||||
* @param expected_reward return-by-reference the total reward awarded to the miner finding this block, including transaction fees
|
||||
* @param ex_nonce extra data to be added to the miner transaction's extra
|
||||
*
|
||||
* @return true if block template filled in successfully, else false
|
||||
*/
|
||||
bool create_block_template(block& b, const account_public_address& miner_address, difficulty_type& di, uint64_t& height, const blobdata& ex_nonce);
|
||||
bool create_block_template(block& b, const account_public_address& miner_address, difficulty_type& di, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce);
|
||||
|
||||
/**
|
||||
* @brief checks if a block is known about with a given hash
|
||||
|
|
|
@ -827,9 +827,9 @@ namespace cryptonote
|
|||
m_mempool.set_relayed(txs);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, const blobdata& ex_nonce)
|
||||
bool core::get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce)
|
||||
{
|
||||
return m_blockchain_storage.create_block_template(b, adr, diffic, height, ex_nonce);
|
||||
return m_blockchain_storage.create_block_template(b, adr, diffic, height, expected_reward, ex_nonce);
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::find_blockchain_supplement(const std::list<crypto::hash>& qblock_ids, NOTIFY_RESPONSE_CHAIN_ENTRY::request& resp) const
|
||||
|
|
|
@ -180,7 +180,7 @@ namespace cryptonote
|
|||
*
|
||||
* @note see Blockchain::create_block_template
|
||||
*/
|
||||
virtual bool get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, const blobdata& ex_nonce);
|
||||
virtual bool get_block_template(block& b, const account_public_address& adr, difficulty_type& diffic, uint64_t& height, uint64_t& expected_reward, const blobdata& ex_nonce);
|
||||
|
||||
/**
|
||||
* @brief called when a transaction is relayed
|
||||
|
|
|
@ -613,7 +613,7 @@ namespace cryptonote
|
|||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
//TODO: investigate whether boolean return is appropriate
|
||||
bool tx_memory_pool::fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint8_t version)
|
||||
bool tx_memory_pool::fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t &expected_reward, uint8_t version)
|
||||
{
|
||||
// Warning: This function takes already_generated_
|
||||
// coins as an argument and appears to do nothing
|
||||
|
@ -705,6 +705,7 @@ namespace cryptonote
|
|||
LOG_PRINT_L2(" added, new block size " << total_size << "/" << max_total_size << ", coinbase " << print_money(best_coinbase));
|
||||
}
|
||||
|
||||
expected_reward = best_coinbase;
|
||||
LOG_PRINT_L2("Block template filled with " << bl.tx_hashes.size() << " txes, size "
|
||||
<< total_size << "/" << max_total_size << ", coinbase " << print_money(best_coinbase)
|
||||
<< " (including " << print_money(fee) << " in fees)");
|
||||
|
|
|
@ -220,11 +220,12 @@ namespace cryptonote
|
|||
* @param already_generated_coins the current total number of coins "minted"
|
||||
* @param total_size return-by-reference the total size of the new block
|
||||
* @param fee return-by-reference the total of fees from the included transactions
|
||||
* @param expected_reward return-by-reference the total reward awarded to the miner finding this block, including transaction fees
|
||||
* @param version hard fork version to use for consensus rules
|
||||
*
|
||||
* @return true
|
||||
*/
|
||||
bool fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint8_t version);
|
||||
bool fill_block_template(block &bl, size_t median_size, uint64_t already_generated_coins, size_t &total_size, uint64_t &fee, uint64_t &expected_reward, uint8_t version);
|
||||
|
||||
/**
|
||||
* @brief get a list of all transactions in the pool
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue