diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-10-27 10:01:20 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2015-10-27 10:01:20 +0000 |
commit | 4f873bcbaa7cbf8733ed9ffc4f136256cb90d447 (patch) | |
tree | ec22aea9d7c100757d097a798774a9edb66cf82f /src/blockchain_db | |
parent | Merge pull request #453 (diff) | |
download | monero-4f873bcbaa7cbf8733ed9ffc4f136256cb90d447.tar.xz |
Remove some old/obsolete/unused code
git history's here if needed to get any of this back
Diffstat (limited to 'src/blockchain_db')
-rw-r--r-- | src/blockchain_db/berkeleydb/db_bdb.cpp | 16 | ||||
-rw-r--r-- | src/blockchain_db/berkeleydb/db_bdb.h | 12 | ||||
-rw-r--r-- | src/blockchain_db/blockchain_db.h | 4 | ||||
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 109 | ||||
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.h | 15 |
5 files changed, 0 insertions, 156 deletions
diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index c387d0362..a980703ec 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -1536,22 +1536,6 @@ output_data_t BlockchainBDB::get_output_key(const uint64_t& amount, const uint64 return get_output_key(glob_index); } -// As this is not used, its return is now a blank output. -// This will save on space in the db. -tx_out BlockchainBDB::get_output(const crypto::hash& h, const uint64_t& index) const -{ - LOG_PRINT_L3("BlockchainBDB::" << __func__); - return tx_out(); -} - -// As this is not used, its return is now a blank output. -// This will save on space in the db. -tx_out BlockchainBDB::get_output(const uint64_t& index) const -{ - LOG_PRINT_L3("BlockchainBDB::" << __func__); - return tx_out(); -} - tx_out_index BlockchainBDB::get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) { LOG_PRINT_L3("BlockchainBDB::" << __func__); diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h index a3383b2b6..6bc9cb4f1 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.h +++ b/src/blockchain_db/berkeleydb/db_bdb.h @@ -300,18 +300,6 @@ public: virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index); virtual output_data_t get_output_key(const uint64_t& global_index) const; virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs); - virtual tx_out get_output(const crypto::hash& h, const uint64_t& index) const; - - /** - * @brief get an output from its global index - * - * @param index global index of the output desired - * - * @return the output associated with the index. - * Will throw OUTPUT_DNE if not output has that global index. - * Will throw DB_ERROR if there is a non-specific LMDB error in fetching - */ - tx_out get_output(const uint64_t& index) const; virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const; virtual void get_output_tx_and_index_from_global(const std::vector<uint64_t> &global_indices, diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h index 1666e57c5..85144f04c 100644 --- a/src/blockchain_db/blockchain_db.h +++ b/src/blockchain_db/blockchain_db.h @@ -106,7 +106,6 @@ * Outputs: * uint64_t get_num_outputs(amount) * pub_key get_output_key(amount, index) - * tx_out get_output(tx_hash, index) * hash,index get_output_tx_and_index_from_global(index) * hash,index get_output_tx_and_index(amount, index) * vec<uint64> get_tx_output_indices(tx_hash) @@ -469,9 +468,6 @@ public: virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index) = 0; virtual output_data_t get_output_key(const uint64_t& global_index) const = 0; - // returns the output indexed by <index> in the transaction with hash <h> - virtual tx_out get_output(const crypto::hash& h, const uint64_t& index) const = 0; - // returns the tx hash associated with an output, referenced by global output index virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const = 0; diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index fc4f59cc3..9acb63364 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -195,8 +195,6 @@ const char* const LMDB_OUTPUT_TXS = "output_txs"; const char* const LMDB_OUTPUT_INDICES = "output_indices"; const char* const LMDB_OUTPUT_AMOUNTS = "output_amounts"; const char* const LMDB_OUTPUT_KEYS = "output_keys"; -const char* const LMDB_OUTPUTS = "outputs"; -const char* const LMDB_OUTPUT_GINDICES = "output_gindices"; const char* const LMDB_SPENT_KEYS = "spent_keys"; const char* const LMDB_HF_STARTING_HEIGHTS = "hf_starting_heights"; @@ -691,19 +689,6 @@ void BlockchainLMDB::add_output(const crypto::hash& tx_hash, const tx_out& tx_ou throw0(DB_ERROR("Failed to add output pubkey to db transaction")); } - -/****** Uncomment if ever outputs actually need to be stored in this manner - * - blobdata b = output_to_blob(tx_output); - - v.mv_size = b.size(); - v.mv_data = &b; - if (mdb_put(*m_write_txn, m_outputs, &k, &v, 0)) - throw0(DB_ERROR("Failed to add output to db transaction")); - if (mdb_put(*m_write_txn, m_output_gindices, &v, &k, 0)) - throw0(DB_ERROR("Failed to add output global index to db transaction")); -************************************************************************/ - m_num_outputs++; } @@ -760,26 +745,6 @@ void BlockchainLMDB::remove_output(const uint64_t& out_index, const uint64_t amo MDB_val_copy<uint64_t> k(out_index); -/****** Uncomment if ever outputs actually need to be stored in this manner - blobdata b; - t_serializable_object_to_blob(tx_output, b); - k.mv_size = b.size(); - k.mv_data = &b; - - if (mdb_get(*m_write_txn, m_output_gindices, &k, &v)) - throw1(OUTPUT_DNE("Attempting to remove output that does not exist")); - - uint64_t gindex = *(uint64_t*)v.mv_data; - - auto result = mdb_del(*m_write_txn, m_output_gindices, &k, NULL); - if (result != 0 && result != MDB_NOTFOUND) - throw1(OUTPUT_DNE("Error adding removal of output global index to db transaction")); - - result = mdb_del(*m_write_txn, m_outputs, &v, NULL); - if (result != 0 && result != MDB_NOTFOUND) - throw1(DB_ERROR("Error adding removal of output to db transaction")); -*********************************************************************/ - auto result = mdb_del(*m_write_txn, m_output_indices, &k, NULL); if (result == MDB_NOTFOUND) { @@ -1053,11 +1018,6 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags) lmdb_db_open(txn, LMDB_OUTPUT_AMOUNTS, MDB_INTEGERKEY | MDB_DUPSORT | MDB_DUPFIXED | MDB_CREATE, m_output_amounts, "Failed to open db handle for m_output_amounts"); lmdb_db_open(txn, LMDB_OUTPUT_KEYS, MDB_INTEGERKEY | MDB_CREATE, m_output_keys, "Failed to open db handle for m_output_keys"); -/*************** not used, but kept for posterity - lmdb_db_open(txn, LMDB_OUTPUTS, MDB_INTEGERKEY | MDB_CREATE, m_outputs, "Failed to open db handle for m_outputs"); - lmdb_db_open(txn, LMDB_OUTPUT_GINDICES, MDB_CREATE, m_output_gindices, "Failed to open db handle for m_output_gindices"); -*************************************************/ - lmdb_db_open(txn, LMDB_SPENT_KEYS, MDB_CREATE, m_spent_keys, "Failed to open db handle for m_spent_keys"); lmdb_db_open(txn, LMDB_HF_STARTING_HEIGHTS, MDB_CREATE, m_hf_starting_heights, "Failed to open db handle for m_hf_starting_heights"); @@ -1787,75 +1747,6 @@ output_data_t BlockchainLMDB::get_output_key(const uint64_t& amount, const uint6 return get_output_key(glob_index); } -tx_out BlockchainLMDB::get_output(const crypto::hash& h, const uint64_t& index) const -{ - LOG_PRINT_L3("BlockchainLMDB::" << __func__); - check_open(); - - mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); - - lmdb_cur cur(txn, m_tx_outputs); - - MDB_val_copy<crypto::hash> k(h); - MDB_val v; - auto result = mdb_cursor_get(cur, &k, &v, MDB_SET); - if (result == MDB_NOTFOUND) - throw1(OUTPUT_DNE("Attempting to get an output by tx hash and tx index, but output not found")); - else if (result) - throw0(DB_ERROR("DB error attempting to get an output")); - - size_t num_elems = 0; - mdb_cursor_count(cur, &num_elems); - if (num_elems <= index) - throw1(OUTPUT_DNE("Attempting to get an output by tx hash and tx index, but output not found")); - - mdb_cursor_get(cur, &k, &v, MDB_FIRST_DUP); - - for (uint64_t i = 0; i < index; ++i) - { - mdb_cursor_get(cur, &k, &v, MDB_NEXT_DUP); - } - - mdb_cursor_get(cur, &k, &v, MDB_GET_CURRENT); - - blobdata b; - b = *(blobdata*)v.mv_data; - - cur.close(); - txn.commit(); - - return output_from_blob(b); -} - -// As this is not used, its return is now a blank output. -// This will save on space in the db. -tx_out BlockchainLMDB::get_output(const uint64_t& index) const -{ - return tx_out(); - LOG_PRINT_L3("BlockchainLMDB::" << __func__); - check_open(); - - mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) - throw0(DB_ERROR("Failed to create a transaction for the db")); - - MDB_val_copy<uint64_t> k(index); - MDB_val v; - auto get_result = mdb_get(txn, m_outputs, &k, &v); - if (get_result == MDB_NOTFOUND) - { - throw OUTPUT_DNE("Attempting to get output by global index, but output does not exist"); - } - else if (get_result) - throw0(DB_ERROR("Error attempting to retrieve an output from the db")); - - blobdata b = *(blobdata*)v.mv_data; - - return output_from_blob(b); -} - tx_out_index BlockchainLMDB::get_output_tx_and_index_from_global(const uint64_t& index) const { LOG_PRINT_L3("BlockchainLMDB::" << __func__); diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h index 85c2dffca..98546620b 100644 --- a/src/blockchain_db/lmdb/db_lmdb.h +++ b/src/blockchain_db/lmdb/db_lmdb.h @@ -163,19 +163,6 @@ public: virtual output_data_t get_output_key(const uint64_t& global_index) const; virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs); - virtual tx_out get_output(const crypto::hash& h, const uint64_t& index) const; - - /** - * @brief get an output from its global index - * - * @param index global index of the output desired - * - * @return the output associated with the index. - * Will throw OUTPUT_DNE if not output has that global index. - * Will throw DB_ERROR if there is a non-specific LMDB error in fetching - */ - tx_out get_output(const uint64_t& index) const; - virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const; virtual void get_output_tx_and_index_from_global(const std::vector<uint64_t> &global_indices, std::vector<tx_out_index> &tx_out_indices) const; @@ -296,10 +283,8 @@ private: MDB_dbi m_output_txs; MDB_dbi m_output_indices; - MDB_dbi m_output_gindices; MDB_dbi m_output_amounts; MDB_dbi m_output_keys; - MDB_dbi m_outputs; MDB_dbi m_spent_keys; |