mirror of
https://github.com/oxen-io/oxen-core.git
synced 2023-12-14 02:22:56 +01:00
Remove unmaintained & fails-to-compile block template creation code
This code references m_tx_pool.m_transactions which got removed in Monero 11, so apparently no one has noticed or tested anything here since then (despite adding new commits into it).
This commit is contained in:
parent
1e496975b3
commit
d38e7aa7b2
3 changed files with 0 additions and 90 deletions
|
@ -1379,11 +1379,6 @@ uint64_t Blockchain::get_current_cumulative_block_weight_median() const
|
|||
// unchanged for the time being.
|
||||
//
|
||||
// This function makes a new block for a miner to mine the hash for
|
||||
//
|
||||
// FIXME: this codebase references #if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
// 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 crypto::hash *from_block, 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__);
|
||||
|
@ -1496,63 +1491,6 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
|
|||
return false;
|
||||
}
|
||||
pool_cookie = m_tx_pool.cookie();
|
||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
size_t real_txs_weight = 0;
|
||||
uint64_t real_fee = 0;
|
||||
for(crypto::hash &cur_hash: b.tx_hashes)
|
||||
{
|
||||
auto cur_res = m_tx_pool.m_transactions.find(cur_hash);
|
||||
if (cur_res == m_tx_pool.m_transactions.end())
|
||||
{
|
||||
LOG_ERROR("Creating block template: error: transaction not found");
|
||||
continue;
|
||||
}
|
||||
tx_memory_pool::tx_details &cur_tx = cur_res->second;
|
||||
real_txs_weight += cur_tx.weight;
|
||||
real_fee += cur_tx.fee;
|
||||
if (cur_tx.weight != get_transaction_weight(cur_tx.tx))
|
||||
{
|
||||
LOG_ERROR("Creating block template: error: invalid transaction weight");
|
||||
}
|
||||
if (cur_tx.tx.version == txversion::v1)
|
||||
{
|
||||
uint64_t inputs_amount;
|
||||
if (!get_inputs_money_amount(cur_tx.tx, inputs_amount))
|
||||
{
|
||||
LOG_ERROR("Creating block template: error: cannot get inputs amount");
|
||||
}
|
||||
else if (cur_tx.fee != inputs_amount - get_outs_money_amount(cur_tx.tx))
|
||||
{
|
||||
LOG_ERROR("Creating block template: error: invalid fee");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool fee_good;
|
||||
if (b.major_version >= HF_VERSION_FEE_BURNING)
|
||||
fee_good = cur_tx.tx.rct_signatures.txnFee + get_burned_amount_from_tx_extra(tx.extra) == cur_tx.fee;
|
||||
else
|
||||
fee_good = cur_tx.tx.rct_signatures.txnFee == cur_tx.fee;
|
||||
if (!fee_good)
|
||||
{
|
||||
LOG_ERROR("Creating block template: error: invalid fee");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (txs_weight != real_txs_weight)
|
||||
{
|
||||
LOG_ERROR("Creating block template: error: wrongly calculated transaction weight");
|
||||
}
|
||||
if (fee != real_fee)
|
||||
{
|
||||
LOG_ERROR("Creating block template: error: wrongly calculated fee");
|
||||
}
|
||||
MDEBUG("Creating block template: height " << height <<
|
||||
", median weight " << median_weight <<
|
||||
", already generated coins " << already_generated_coins <<
|
||||
", transaction weight " << txs_weight <<
|
||||
", fee " << fee);
|
||||
#endif
|
||||
|
||||
/*
|
||||
two-phase miner transaction generation: we don't know exact block weight until we prepare block, but we don't know reward until we know
|
||||
|
@ -1571,10 +1509,6 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
|
|||
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to construct miner tx, first chance");
|
||||
size_t cumulative_weight = txs_weight + get_transaction_weight(b.miner_tx);
|
||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
MDEBUG("Creating block template: miner tx weight " << get_transaction_weight(b.miner_tx) <<
|
||||
", cumulative weight " << cumulative_weight);
|
||||
#endif
|
||||
for (size_t try_count = 0; try_count != 10; ++try_count)
|
||||
{
|
||||
r = construct_miner_tx(height, median_weight, already_generated_coins, cumulative_weight, fee, miner_address, b.miner_tx, ex_nonce, hf_version, miner_tx_context);
|
||||
|
@ -1584,21 +1518,12 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
|
|||
if (coinbase_weight > cumulative_weight - txs_weight)
|
||||
{
|
||||
cumulative_weight = txs_weight + coinbase_weight;
|
||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
MDEBUG("Creating block template: miner tx weight " << coinbase_weight <<
|
||||
", cumulative weight " << cumulative_weight << " is greater than before");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
if (coinbase_weight < cumulative_weight - txs_weight)
|
||||
{
|
||||
size_t delta = cumulative_weight - txs_weight - coinbase_weight;
|
||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
MDEBUG("Creating block template: miner tx weight " << coinbase_weight <<
|
||||
", cumulative weight " << txs_weight + coinbase_weight <<
|
||||
" is less than before, adding " << delta << " zero bytes");
|
||||
#endif
|
||||
b.miner_tx.extra.insert(b.miner_tx.extra.end(), delta, 0);
|
||||
//here could be 1 byte difference, because of extra field counter is varint, and it can become from 1-byte len to 2-bytes len.
|
||||
if (cumulative_weight != txs_weight + get_transaction_weight(b.miner_tx))
|
||||
|
@ -1616,10 +1541,6 @@ bool Blockchain::create_block_template(block& b, const crypto::hash *from_block,
|
|||
}
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(cumulative_weight == txs_weight + get_transaction_weight(b.miner_tx), false, "unexpected case: cumulative_weight=" << cumulative_weight << " is not equal txs_cumulative_weight=" << txs_weight << " + get_transaction_weight(b.miner_tx)=" << get_transaction_weight(b.miner_tx));
|
||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
MDEBUG("Creating block template: miner tx weight " << coinbase_weight <<
|
||||
", cumulative weight " << cumulative_weight << " is now good");
|
||||
#endif
|
||||
|
||||
if (!from_block)
|
||||
cache_block_template(b, miner_address, ex_nonce, diffic, height, expected_reward, pool_cookie);
|
||||
|
|
|
@ -279,11 +279,6 @@ namespace cryptonote
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
LOG_PRINT_L1("Creating block template: reward " << block_reward <<
|
||||
", fee " << fee);
|
||||
#endif
|
||||
|
||||
uint64_t summary_amounts = 0;
|
||||
// Miner Reward
|
||||
{
|
||||
|
|
|
@ -547,13 +547,7 @@ namespace cryptonote
|
|||
*/
|
||||
typedef std::unordered_map<crypto::key_image, std::unordered_set<crypto::hash> > key_images_container;
|
||||
|
||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
public:
|
||||
#endif
|
||||
mutable epee::critical_section m_transactions_lock; //!< lock for the pool
|
||||
#if defined(DEBUG_CREATE_BLOCK_TEMPLATE)
|
||||
private:
|
||||
#endif
|
||||
|
||||
//! container for spent key images from the transactions in the pool
|
||||
key_images_container m_spent_key_images;
|
||||
|
|
Loading…
Reference in a new issue