From e7278c0add0fdca1335cba31d07ad9492d794014 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 28 Jul 2026 07:43:43 +0200 Subject: [PATCH] cryptonote_core: remove dead code Never had a caller: - Blockchain::init taking HardFork*&: added in 8f863e742, no caller in any revision since - tx_memory_pool::get_txpool_weight, set_txpool_max_weight: added as get_txpool_size and set_txpool_max_size in bc61ae69b alongside --max-txpool-size, which is wired through tx_memory_pool::init instead; renamed size to weight in 5ffb2ff9b, still uncalled - get_transaction_version: added in b750fb27b, no caller since Dead when their last user went: - core::get_blocks taking vector>, both overloads: last caller removed in 9faef1f83; ed2c81ed9 later converted the already-dead signatures from std::list to std::vector. The vector overload is still used by core_tests and is kept - blocks_container: 9e82b694d removed the in-memory blockchain that used it - tx_by_fee_and_receive_time_entry: 445319d3f replaced the sorted container it keyed with a boost::bimap - m_store_blockchain_interval: its do_call went with the original blockchain_storage format in 9e82b694d - m_fork_moaner: its do_call went with the "We are most likely forked" message in f0371210e Also drops two break statements after a return in ver_mixed_rct_semantics and the doc comments belonging to the removed declarations. --- src/cryptonote_core/blockchain.cpp | 21 ------------------- src/cryptonote_core/blockchain.h | 14 ------------- src/cryptonote_core/cryptonote_core.cpp | 10 --------- src/cryptonote_core/cryptonote_core.h | 16 -------------- src/cryptonote_core/tx_pool.cpp | 12 ----------- src/cryptonote_core/tx_pool.h | 17 --------------- src/cryptonote_core/tx_verification_utils.cpp | 2 -- 7 files changed, 92 deletions(-) diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 6a902110a..8c9760590 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -463,16 +463,6 @@ bool Blockchain::init(BlockchainDB* db, const network_type nettype, bool offline return true; } //------------------------------------------------------------------ -bool Blockchain::init(BlockchainDB* db, HardFork*& hf, const network_type nettype, bool offline) -{ - if (hf != nullptr) - m_hardfork = hf; - bool res = init(db, nettype, offline, NULL); - if (hf == nullptr) - hf = m_hardfork; - return res; -} -//------------------------------------------------------------------ bool Blockchain::store_blockchain() { LOG_PRINT_L3("Blockchain::" << __func__); @@ -2637,17 +2627,6 @@ bool Blockchain::get_transactions_blobs(const std::vector& txs_ids return true; } //------------------------------------------------------------------ -size_t get_transaction_version(const cryptonote::blobdata &bd) -{ - size_t version; - const char* begin = static_cast(bd.data()); - const char* end = begin + bd.size(); - int read = tools::read_varint(begin, end, version); - if (read <= 0) - throw std::runtime_error("Internal error getting transaction version"); - return version; -} -//------------------------------------------------------------------ template bool Blockchain::get_split_transactions_blobs(const t_ids_container& txs_ids, t_tx_container& txs, t_missed_container& missed_txs) const { diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 5062f9987..79c1c2640 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -133,18 +133,6 @@ namespace cryptonote */ bool init(BlockchainDB* db, const network_type nettype = MAINNET, bool offline = false, const cryptonote::test_options *test_options = NULL, difficulty_type fixed_difficulty = 0, const GetCheckpointsCallback& get_checkpoints = nullptr); - /** - * @brief Initialize the Blockchain state - * - * @param db a pointer to the backing store to use for the blockchain - * @param hf a structure containing hardfork information - * @param nettype network type - * @param offline true if running offline, else false - * - * @return true on success, false if any initialization steps fail - */ - bool init(BlockchainDB* db, HardFork*& hf, const network_type nettype = MAINNET, bool offline = false); - /** * @brief Uninitializes the blockchain state * @@ -1177,8 +1165,6 @@ namespace cryptonote // TODO: evaluate whether or not each of these typedefs are left over from blockchain_storage typedef std::unordered_set key_images_container; - typedef std::vector blocks_container; - typedef std::unordered_map blocks_ext_by_hash; diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index b08939f17..86b934d32 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -395,16 +395,6 @@ namespace cryptonote top_id = m_blockchain_storage.get_tail_id(height); } //----------------------------------------------------------------------------------------------- - bool core::get_blocks(uint64_t start_offset, size_t count, std::vector>& blocks, std::vector& txs) const - { - return m_blockchain_storage.get_blocks(start_offset, count, blocks, txs); - } - //----------------------------------------------------------------------------------------------- - bool core::get_blocks(uint64_t start_offset, size_t count, std::vector>& blocks) const - { - return m_blockchain_storage.get_blocks(start_offset, count, blocks); - } - //----------------------------------------------------------------------------------------------- bool core::get_blocks(uint64_t start_offset, size_t count, std::vector& blocks) const { std::vector> bs; diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 505e52f23..66fa9d767 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -331,20 +331,6 @@ namespace cryptonote */ void get_blockchain_top(uint64_t& height, crypto::hash& top_id) const; - /** - * @copydoc Blockchain::get_blocks(uint64_t, size_t, std::vector>&, std::vector&) const - * - * @note see Blockchain::get_blocks(uint64_t, size_t, std::vector>&, std::vector&) const - */ - bool get_blocks(uint64_t start_offset, size_t count, std::vector>& blocks, std::vector& txs) const; - - /** - * @copydoc Blockchain::get_blocks(uint64_t, size_t, std::vector>&) const - * - * @note see Blockchain::get_blocks(uint64_t, size_t, std::vector>&) const - */ - bool get_blocks(uint64_t start_offset, size_t count, std::vector>& blocks) const; - /** * @copydoc Blockchain::get_blocks(uint64_t, size_t, std::vector>&) const * @@ -1056,8 +1042,6 @@ namespace cryptonote cryptonote_protocol_stub m_protocol_stub; //!< cryptonote protocol stub instance - epee::math_helper::once_a_time_seconds<60*60*12, false> m_store_blockchain_interval; //!< interval for manual storing of Blockchain, if enabled - epee::math_helper::once_a_time_seconds<60*60*2, true> m_fork_moaner; //!< interval for checking HardFork status epee::math_helper::once_a_time_seconds<60*60*12, true> m_check_updates_interval; //!< interval for checking for new versions epee::math_helper::once_a_time_seconds<60*10, true> m_check_disk_space_interval; //!< interval for checking for disk space epee::math_helper::once_a_time_seconds<90, false> m_block_rate_interval; //!< interval for checking block rate diff --git a/src/cryptonote_core/tx_pool.cpp b/src/cryptonote_core/tx_pool.cpp index 4bc723a30..3f2d9b861 100644 --- a/src/cryptonote_core/tx_pool.cpp +++ b/src/cryptonote_core/tx_pool.cpp @@ -371,18 +371,6 @@ namespace cryptonote nic_verified_hf_version, valid_input_verification_id); } //--------------------------------------------------------------------------------- - size_t tx_memory_pool::get_txpool_weight() const - { - CRITICAL_REGION_LOCAL(m_transactions_lock); - return m_txpool_weight; - } - //--------------------------------------------------------------------------------- - void tx_memory_pool::set_txpool_max_weight(size_t bytes) - { - CRITICAL_REGION_LOCAL(m_transactions_lock); - m_txpool_max_weight = bytes; - } - //--------------------------------------------------------------------------------- void tx_memory_pool::reduce_txpool_weight(size_t weight) { if (weight > m_txpool_weight) diff --git a/src/cryptonote_core/tx_pool.h b/src/cryptonote_core/tx_pool.h index ee541619e..e3f075823 100644 --- a/src/cryptonote_core/tx_pool.h +++ b/src/cryptonote_core/tx_pool.h @@ -61,9 +61,6 @@ namespace cryptonote /* */ /************************************************************************/ - //! pair of for organization - typedef std::pair, crypto::hash> tx_by_fee_and_receive_time_entry; - class txFeeCompare { public: @@ -423,20 +420,6 @@ namespace cryptonote */ uint64_t cookie() const { return m_cookie; } - /** - * @brief get the cumulative txpool weight in bytes - * - * @return the cumulative txpool weight in bytes - */ - size_t get_txpool_weight() const; - - /** - * @brief set the max cumulative txpool weight in bytes - * - * @param bytes the max cumulative txpool weight in bytes - */ - void set_txpool_max_weight(size_t bytes); - /** * @brief reduce the cumulative txpool weight by the weight provided * diff --git a/src/cryptonote_core/tx_verification_utils.cpp b/src/cryptonote_core/tx_verification_utils.cpp index aee5aa3dc..652965a71 100644 --- a/src/cryptonote_core/tx_verification_utils.cpp +++ b/src/cryptonote_core/tx_verification_utils.cpp @@ -406,7 +406,6 @@ bool ver_mixed_rct_semantics(std::vector rvv) // coinbase should not come here, so we reject for all other types MERROR("Unexpected Null rctSig type"); return false; - break; case rct::RCTTypeSimple: if (!rct::verRctSemanticsSimple(rv)) { @@ -442,7 +441,6 @@ bool ver_mixed_rct_semantics(std::vector rvv) default: MERROR("Unknown rct type: " << rv.type); return false; - break; } // Save this ring sig for later, as we will attempt simple RCT semantics batch verification