From 4c341da1e5102b6b727b7df856a727ae9438a88e Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Fri, 30 May 2025 12:11:34 -0500 Subject: [PATCH] BlockchainLMDB: remove `virtual` qualifers from overriden methods and mark `final` According to guideline at https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines.html#c128-virtual-functions-should-specify-exactly-one-of-virtual-override-or-final Co-authored-by: SNeedlewoods Co-authored-by: Lee *!* Clagett --- src/blockchain_db/lmdb/db_lmdb.h | 214 +++++++++++++++---------------- 1 file changed, 107 insertions(+), 107 deletions(-) diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index 536f119a34..45b3f37092 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -180,137 +180,137 @@ struct mdb_txn_safe // A regular network sync without batch writes is expected to open a new read // transaction, as those lookups are part of the validation done prior to the // write for block and tx data, so no write transaction is open at the time. -class BlockchainLMDB : public BlockchainDB +class BlockchainLMDB final: public BlockchainDB { public: BlockchainLMDB(bool batch_transactions=true); ~BlockchainLMDB(); - virtual void open(const std::string& filename, const int mdb_flags=0) override; + void open(const std::string& filename, const int mdb_flags=0) override; - virtual void close() override; + void close() override; - virtual void sync() override; + void sync() override; - virtual void safesyncmode(const bool onoff) override; + void safesyncmode(const bool onoff) override; - virtual void reset() override; + void reset() override; - virtual std::vector get_filenames() const override; + std::vector get_filenames() const override; - virtual bool remove_data_file(const std::string& folder) const override; + bool remove_data_file(const std::string& folder) const override; - virtual std::string get_db_name() const override; + std::string get_db_name() const override; - virtual bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const override; + bool block_exists(const crypto::hash& h, uint64_t *height = NULL) const override; - virtual uint64_t get_block_height(const crypto::hash& h) const override; + uint64_t get_block_height(const crypto::hash& h) const override; - virtual block_header get_block_header(const crypto::hash& h) const override; + block_header get_block_header(const crypto::hash& h) const override; - virtual cryptonote::blobdata get_block_blob(const crypto::hash& h) const override; + cryptonote::blobdata get_block_blob(const crypto::hash& h) const override; - virtual cryptonote::blobdata get_block_blob_from_height(const uint64_t& height) const override; + cryptonote::blobdata get_block_blob_from_height(const uint64_t& height) const override; - virtual std::vector get_block_cumulative_rct_outputs(const std::vector &heights) const override; + std::vector get_block_cumulative_rct_outputs(const std::vector &heights) const override; - virtual uint64_t get_block_timestamp(const uint64_t& height) const override; + uint64_t get_block_timestamp(const uint64_t& height) const override; - virtual uint64_t get_top_block_timestamp() const override; + uint64_t get_top_block_timestamp() const override; - virtual size_t get_block_weight(const uint64_t& height) const override; + size_t get_block_weight(const uint64_t& height) const override; - virtual std::vector get_block_weights(uint64_t start_height, size_t count) const override; + std::vector get_block_weights(uint64_t start_height, size_t count) const override; - virtual difficulty_type get_block_cumulative_difficulty(const uint64_t& height) const override; + difficulty_type get_block_cumulative_difficulty(const uint64_t& height) const override; - virtual difficulty_type get_block_difficulty(const uint64_t& height) const override; + difficulty_type get_block_difficulty(const uint64_t& height) const override; - virtual void correct_block_cumulative_difficulties(const uint64_t& start_height, const std::vector& new_cumulative_difficulties) override; + void correct_block_cumulative_difficulties(const uint64_t& start_height, const std::vector& new_cumulative_difficulties) override; - virtual uint64_t get_block_already_generated_coins(const uint64_t& height) const override; + uint64_t get_block_already_generated_coins(const uint64_t& height) const override; - virtual uint64_t get_block_long_term_weight(const uint64_t& height) const override; + uint64_t get_block_long_term_weight(const uint64_t& height) const override; - virtual std::vector get_long_term_block_weights(uint64_t start_height, size_t count) const override; + std::vector get_long_term_block_weights(uint64_t start_height, size_t count) const override; - virtual crypto::hash get_block_hash_from_height(const uint64_t& height) const override; + crypto::hash get_block_hash_from_height(const uint64_t& height) const override; - virtual std::vector get_blocks_range(const uint64_t& h1, const uint64_t& h2) const override; + std::vector get_blocks_range(const uint64_t& h1, const uint64_t& h2) const override; - virtual std::vector get_hashes_range(const uint64_t& h1, const uint64_t& h2) const override; + std::vector get_hashes_range(const uint64_t& h1, const uint64_t& h2) const override; - virtual crypto::hash top_block_hash(uint64_t *block_height = NULL) const override; + crypto::hash top_block_hash(uint64_t *block_height = NULL) const override; - virtual block get_top_block() const override; + block get_top_block() const override; - virtual uint64_t height() const override; + uint64_t height() const override; - virtual bool tx_exists(const crypto::hash& h) const override; - virtual bool tx_exists(const crypto::hash& h, uint64_t& tx_index) const override; + bool tx_exists(const crypto::hash& h) const override; + bool tx_exists(const crypto::hash& h, uint64_t& tx_index) const override; - virtual uint64_t get_tx_unlock_time(const crypto::hash& h) const override; + uint64_t get_tx_unlock_time(const crypto::hash& h) const override; - virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override; - virtual bool get_pruned_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override; - virtual bool get_pruned_tx_blobs_from(const crypto::hash& h, size_t count, std::vector &bd) const override; - virtual bool get_blocks_from(uint64_t start_height, size_t min_block_count, size_t max_block_count, size_t max_tx_count, size_t max_size, std::vector, std::vector>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const override; - virtual bool get_prunable_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override; - virtual bool get_prunable_tx_hash(const crypto::hash& tx_hash, crypto::hash &prunable_hash) const override; + bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override; + bool get_pruned_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override; + bool get_pruned_tx_blobs_from(const crypto::hash& h, size_t count, std::vector &bd) const override; + bool get_blocks_from(uint64_t start_height, size_t min_block_count, size_t max_block_count, size_t max_tx_count, size_t max_size, std::vector, std::vector>>>& blocks, bool pruned, bool skip_coinbase, bool get_miner_tx_hash) const override; + bool get_prunable_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const override; + bool get_prunable_tx_hash(const crypto::hash& tx_hash, crypto::hash &prunable_hash) const override; - virtual std::vector get_txids_loose(const crypto::hash& h, std::uint32_t bits, uint64_t max_num_txs = 0) override; + std::vector get_txids_loose(const crypto::hash& h, std::uint32_t bits, uint64_t max_num_txs = 0) override; - virtual uint64_t get_tx_count() const override; + uint64_t get_tx_count() const override; - virtual std::vector get_tx_list(const std::vector& hlist) const override; + std::vector get_tx_list(const std::vector& hlist) const override; - virtual uint64_t get_tx_block_height(const crypto::hash& h) const override; + uint64_t get_tx_block_height(const crypto::hash& h) const override; - virtual uint64_t get_num_outputs(const uint64_t& amount) const override; + uint64_t get_num_outputs(const uint64_t& amount) const override; - virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index, bool include_commitmemt) const override; - virtual void get_output_key(const epee::span &amounts, const std::vector &offsets, std::vector &outputs, bool allow_partial = false) const override; + output_data_t get_output_key(const uint64_t& amount, const uint64_t& index, bool include_commitmemt) const override; + void get_output_key(const epee::span &amounts, const std::vector &offsets, std::vector &outputs, bool allow_partial = false) const override; - virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const override; - virtual void get_output_tx_and_index_from_global(const std::vector &global_indices, + tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const override; + void get_output_tx_and_index_from_global(const std::vector &global_indices, std::vector &tx_out_indices) const; - virtual tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) const override; - virtual void get_output_tx_and_index(const uint64_t& amount, const std::vector &offsets, std::vector &indices) const override; + tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) const override; + void get_output_tx_and_index(const uint64_t& amount, const std::vector &offsets, std::vector &indices) const override; - virtual std::vector> get_tx_amount_output_indices(const uint64_t tx_id, size_t n_txes) const override; + std::vector> get_tx_amount_output_indices(const uint64_t tx_id, size_t n_txes) const override; - virtual bool has_key_image(const crypto::key_image& img) const override; + bool has_key_image(const crypto::key_image& img) const override; - virtual void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata_ref &blob, const txpool_tx_meta_t& meta) override; - virtual void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t& meta) override; - virtual uint64_t get_txpool_tx_count(relay_category category = relay_category::broadcasted) const override; - virtual bool txpool_has_tx(const crypto::hash &txid, relay_category tx_category) const override; - virtual void remove_txpool_tx(const crypto::hash& txid) override; - virtual bool get_txpool_tx_meta(const crypto::hash& txid, txpool_tx_meta_t &meta) const override; - virtual bool get_txpool_tx_blob(const crypto::hash& txid, cryptonote::blobdata& bd, relay_category tx_category) const override; - virtual cryptonote::blobdata get_txpool_tx_blob(const crypto::hash& txid, relay_category tx_category) const override; - virtual uint32_t get_blockchain_pruning_seed() const override; - virtual bool prune_blockchain(uint32_t pruning_seed = 0) override; - virtual bool update_pruning() override; - virtual bool check_pruning() override; + void add_txpool_tx(const crypto::hash &txid, const cryptonote::blobdata_ref &blob, const txpool_tx_meta_t& meta) override; + void update_txpool_tx(const crypto::hash &txid, const txpool_tx_meta_t& meta) override; + uint64_t get_txpool_tx_count(relay_category category = relay_category::broadcasted) const override; + bool txpool_has_tx(const crypto::hash &txid, relay_category tx_category) const override; + void remove_txpool_tx(const crypto::hash& txid) override; + bool get_txpool_tx_meta(const crypto::hash& txid, txpool_tx_meta_t &meta) const override; + bool get_txpool_tx_blob(const crypto::hash& txid, cryptonote::blobdata& bd, relay_category tx_category) const override; + cryptonote::blobdata get_txpool_tx_blob(const crypto::hash& txid, relay_category tx_category) const override; + uint32_t get_blockchain_pruning_seed() const override; + bool prune_blockchain(uint32_t pruning_seed = 0) override; + bool update_pruning() override; + bool check_pruning() override; - virtual void add_alt_block(const crypto::hash &blkid, const cryptonote::alt_block_data_t &data, const cryptonote::blobdata_ref &blob) override; - virtual bool get_alt_block(const crypto::hash &blkid, alt_block_data_t *data, cryptonote::blobdata *blob) override; - virtual void remove_alt_block(const crypto::hash &blkid) override; - virtual uint64_t get_alt_block_count() override; - virtual void drop_alt_blocks() override; + void add_alt_block(const crypto::hash &blkid, const cryptonote::alt_block_data_t &data, const cryptonote::blobdata_ref &blob) override; + bool get_alt_block(const crypto::hash &blkid, alt_block_data_t *data, cryptonote::blobdata *blob) override; + void remove_alt_block(const crypto::hash &blkid) override; + uint64_t get_alt_block_count() override; + void drop_alt_blocks() override; - virtual bool for_all_txpool_txes(std::function f, bool include_blob = false, relay_category category = relay_category::broadcasted) const override; + bool for_all_txpool_txes(std::function f, bool include_blob = false, relay_category category = relay_category::broadcasted) const override; - virtual bool for_all_key_images(std::function) const override; - virtual bool for_blocks_range(const uint64_t& h1, const uint64_t& h2, std::function) const override; - virtual bool for_all_transactions(std::function, bool pruned) const override; - virtual bool for_all_outputs(std::function f) const override; - virtual bool for_all_outputs(uint64_t amount, const std::function &f) const override; - virtual bool for_all_alt_blocks(std::function f, bool include_blob = false) const override; + bool for_all_key_images(std::function) const override; + bool for_blocks_range(const uint64_t& h1, const uint64_t& h2, std::function) const override; + bool for_all_transactions(std::function, bool pruned) const override; + bool for_all_outputs(std::function f) const override; + bool for_all_outputs(uint64_t amount, const std::function &f) const override; + bool for_all_alt_blocks(std::function f, bool include_blob = false) const override; - virtual uint64_t add_block( const std::pair& blk + uint64_t add_block( const std::pair& blk , size_t block_weight , uint64_t long_term_block_weight , const difficulty_type& cumulative_difficulty @@ -318,24 +318,24 @@ public: , const std::vector>& txs ) override; - virtual void set_batch_transactions(bool batch_transactions) override; - virtual bool batch_start(uint64_t batch_num_blocks=0, uint64_t batch_bytes=0) override; - virtual void batch_commit(); - virtual void batch_stop() override; - virtual void batch_abort() override; + void set_batch_transactions(bool batch_transactions) override; + bool batch_start(uint64_t batch_num_blocks=0, uint64_t batch_bytes=0) override; + void batch_commit(); + void batch_stop() override; + void batch_abort() override; - virtual void block_wtxn_start() override; - virtual void block_wtxn_stop() override; - virtual void block_wtxn_abort() override; - virtual bool block_rtxn_start() const override; - virtual void block_rtxn_stop() const override; - virtual void block_rtxn_abort() const override; + void block_wtxn_start() override; + void block_wtxn_stop() override; + void block_wtxn_abort() override; + bool block_rtxn_start() const override; + void block_rtxn_stop() const override; + void block_rtxn_abort() const override; bool block_rtxn_start(MDB_txn **mtxn, mdb_txn_cursors **mcur) const; - virtual void pop_block(block& blk, std::vector& txs) override; + void pop_block(block& blk, std::vector& txs) override; - virtual bool can_thread_bulk_indices() const { return true; } + bool can_thread_bulk_indices() const { return true; } /** * @brief return a histogram of outputs on the blockchain @@ -363,7 +363,7 @@ private: void check_and_resize_for_batch(uint64_t batch_num_blocks, uint64_t batch_bytes); uint64_t get_estimated_batch_size(uint64_t batch_num_blocks, uint64_t batch_bytes) const; - virtual void add_block( const block& blk + void add_block( const block& blk , size_t block_weight , uint64_t long_term_block_weight , const difficulty_type& cumulative_difficulty @@ -372,20 +372,20 @@ private: , const crypto::hash& block_hash ) override; - virtual void remove_block() override; + void remove_block() override; - virtual uint64_t add_transaction_data(const crypto::hash& blk_hash, const transaction& tx, epee::span blob, const crypto::hash& tx_hash, const crypto::hash& tx_prunable_hash) override; + uint64_t add_transaction_data(const crypto::hash& blk_hash, const transaction& tx, epee::span blob, const crypto::hash& tx_hash, const crypto::hash& tx_prunable_hash) override; - virtual void remove_transaction_data(const crypto::hash& tx_hash, const transaction& tx) override; + void remove_transaction_data(const crypto::hash& tx_hash, const transaction& tx) override; - virtual uint64_t add_output(const crypto::hash& tx_hash, + uint64_t add_output(const crypto::hash& tx_hash, const tx_out& tx_output, const uint64_t& local_index, const uint64_t unlock_time, const rct::key *commitment ) override; - virtual void add_tx_amount_output_indices(const uint64_t tx_id, + void add_tx_amount_output_indices(const uint64_t tx_id, const std::vector& amount_output_indices ) override; @@ -393,27 +393,27 @@ private: void remove_output(const uint64_t amount, const uint64_t& out_index); - virtual void prune_outputs(uint64_t amount) override; + void prune_outputs(uint64_t amount) override; - virtual void add_spent_key(const crypto::key_image& k_image) override; + void add_spent_key(const crypto::key_image& k_image) override; - virtual void remove_spent_key(const crypto::key_image& k_image) override; + void remove_spent_key(const crypto::key_image& k_image) override; uint64_t num_outputs() const; // Hard fork - virtual void set_hard_fork_version(uint64_t height, uint8_t version) override; - virtual uint8_t get_hard_fork_version(uint64_t height) const override; - virtual void check_hard_fork_info() override; - virtual void drop_hard_fork_info() override; + void set_hard_fork_version(uint64_t height, uint8_t version) override; + uint8_t get_hard_fork_version(uint64_t height) const override; + void check_hard_fork_info() override; + void drop_hard_fork_info() override; inline void check_open() const; bool prune_worker(int mode, uint32_t pruning_seed); - virtual bool is_read_only() const override; + bool is_read_only() const override; - virtual uint64_t get_database_size() const override; + uint64_t get_database_size() const override; std::vector get_block_info_64bit_fields(uint64_t start_height, size_t count, off_t offset) const; @@ -421,7 +421,7 @@ private: void add_max_block_size(uint64_t sz) override; // fix up anything that may be wrong due to past bugs - virtual void fixup() override; + void fixup() override; // migrate from older DB version to current void migrate(const uint32_t oldversion);