diff options
-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 | ||||
-rw-r--r-- | src/common/http_connection.h | 3 | ||||
-rw-r--r-- | src/common/rpc_client.h | 2 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 49 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.h | 15 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 6 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 10 | ||||
-rw-r--r-- | src/wallet/wallet2.h | 8 | ||||
-rw-r--r-- | tests/unit_tests/hardfork.cpp | 1 |
13 files changed, 15 insertions, 235 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; diff --git a/src/common/http_connection.h b/src/common/http_connection.h index c192e79b6..06024b02a 100644 --- a/src/common/http_connection.h +++ b/src/common/http_connection.h @@ -46,6 +46,7 @@ public: , uint16_t port ) : mp_http_client(p_http_client) + , m_ok(false) { // TODO fix http client so that it accepts properly typed arguments std::string ip_str = epee::string_tools::get_ip_string_from_int32(ip); @@ -61,7 +62,7 @@ public: } } - bool is_open() + bool is_open() const { return m_ok; } diff --git a/src/common/rpc_client.h b/src/common/rpc_client.h index dc9f32c25..2e460912a 100644 --- a/src/common/rpc_client.h +++ b/src/common/rpc_client.h @@ -54,7 +54,7 @@ namespace tools , m_port{port} {} - std::string build_url(std::string const & relative_url) + std::string build_url(std::string const & relative_url) const { std::string result = "http://" diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index a594a1b05..d115d3bd5 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -100,55 +100,6 @@ m_is_blockchain_storing(false), m_enforce_dns_checkpoints(false), m_max_prepare_ LOG_PRINT_L3("Blockchain::" << __func__); } //------------------------------------------------------------------ -//TODO: is this still needed? I don't think so - tewinget -template<class archive_t> -void Blockchain::serialize(archive_t & ar, const unsigned int version) -{ - key_images_container dummy_key_images_container; - - LOG_PRINT_L3("Blockchain::" << __func__); - if(version < 11) - return; - CRITICAL_REGION_LOCAL(m_blockchain_lock); - ar & m_blocks; - ar & m_blocks_index; - ar & m_transactions; - ar & dummy_key_images_container; - ar & m_alternative_chains; - ar & m_outputs; - ar & m_invalid_blocks; - ar & m_current_block_cumul_sz_limit; - /*serialization bug workaround*/ - if(version > 11) - { - uint64_t total_check_count = m_db->height() + m_blocks_index.size() + m_transactions.size() + dummy_key_images_container.size() + m_alternative_chains.size() + m_outputs.size() + m_invalid_blocks.size() + m_current_block_cumul_sz_limit; - if(archive_t::is_saving::value) - { - ar & total_check_count; - } - else - { - uint64_t total_check_count_loaded = 0; - ar & total_check_count_loaded; - if(total_check_count != total_check_count_loaded) - { - LOG_ERROR("Blockchain storage data corruption detected. total_count loaded from file = " << total_check_count_loaded << ", expected = " << total_check_count); - - LOG_PRINT_L0("Blockchain storage:" << std::endl << "m_blocks: " << m_db->height() << std::endl << "m_blocks_index: " << m_blocks_index.size() << std::endl << "m_transactions: " << m_transactions.size() << std::endl << "dummy_key_images_container: " << dummy_key_images_container.size() << std::endl << "m_alternative_chains: " << m_alternative_chains.size() << std::endl << "m_outputs: " << m_outputs.size() << std::endl << "m_invalid_blocks: " << m_invalid_blocks.size() << std::endl << "m_current_block_cumul_sz_limit: " << m_current_block_cumul_sz_limit); - - throw std::runtime_error("Blockchain data corruption"); - } - } - } - - if (version > 12) - { - ar & *m_hardfork; - } - - LOG_PRINT_L3("Blockchain storage:" << std::endl << "m_blocks: " << m_db->height() << std::endl << "m_blocks_index: " << m_blocks_index.size() << std::endl << "m_transactions: " << m_transactions.size() << std::endl << "dummy_key_images_container: " << dummy_key_images_container.size() << std::endl << "m_alternative_chains: " << m_alternative_chains.size() << std::endl << "m_outputs: " << m_outputs.size() << std::endl << "m_invalid_blocks: " << m_invalid_blocks.size() << std::endl << "m_current_block_cumul_sz_limit: " << m_current_block_cumul_sz_limit); -} -//------------------------------------------------------------------ bool Blockchain::have_tx(const crypto::hash &id) const { LOG_PRINT_L3("Blockchain::" << __func__); diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 21bbfb447..00670c6d3 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -107,9 +107,6 @@ namespace cryptonote bool prepare_handle_incoming_blocks(const std::list<block_complete_entry> &blocks); bool cleanup_handle_incoming_blocks(bool force_sync = false); - template<class archive_t> - void serialize(archive_t & ar, const unsigned int version); - bool have_tx(const crypto::hash &id) const; bool have_tx_keyimges_as_spent(const transaction &tx) const; bool have_tx_keyimg_as_spent(const crypto::key_image &key_im) const; @@ -276,16 +273,4 @@ namespace cryptonote void check_ring_signature(const crypto::hash &tx_prefix_hash, const crypto::key_image &key_image, const std::vector<crypto::public_key> &pubkeys, const std::vector<crypto::signature> &sig, uint64_t &result); }; - - - /************************************************************************/ - /* */ - /************************************************************************/ - - #define CURRENT_BLOCKCHAIN_ARCHIVE_VER 13 - - //------------------------------------------------------------------ - } // namespace cryptonote - -BOOST_CLASS_VERSION(cryptonote::Blockchain, CURRENT_BLOCKCHAIN_ARCHIVE_VER) diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 2661dd597..2c8bfc21c 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -1104,12 +1104,12 @@ bool simple_wallet::refresh(const std::vector<std::string>& args) message_writer() << tr("Starting refresh..."); - size_t fetched_blocks = 0; - size_t start_height = 0; + uint64_t fetched_blocks = 0; + uint64_t start_height = 0; if(!args.empty()){ try { - start_height = boost::lexical_cast<int>( args[0] ); + start_height = boost::lexical_cast<uint64_t>( args[0] ); } catch(const boost::bad_lexical_cast &) { diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 92777d16b..167325525 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -349,7 +349,7 @@ void wallet2::get_short_chain_history(std::list<crypto::hash>& ids) const ids.push_back(m_blockchain[0]); } //---------------------------------------------------------------------------------------------------- -void wallet2::pull_blocks(uint64_t start_height, size_t& blocks_added) +void wallet2::pull_blocks(uint64_t start_height, uint64_t& blocks_added) { blocks_added = 0; cryptonote::COMMAND_RPC_GET_BLOCKS_FAST::request req = AUTO_VAL_INIT(req); @@ -400,17 +400,17 @@ void wallet2::refresh() refresh(0, blocks_fetched); } //---------------------------------------------------------------------------------------------------- -void wallet2::refresh(uint64_t start_height, size_t & blocks_fetched) +void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched) { bool received_money = false; refresh(start_height, blocks_fetched, received_money); } //---------------------------------------------------------------------------------------------------- -void wallet2::refresh(uint64_t start_height, size_t & blocks_fetched, bool& received_money) +void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& received_money) { received_money = false; blocks_fetched = 0; - size_t added_blocks = 0; + uint64_t added_blocks = 0; size_t try_count = 0; crypto::hash last_tx_hash_id = m_transfers.size() ? get_transaction_hash(m_transfers.back().m_tx) : null_hash; @@ -444,7 +444,7 @@ void wallet2::refresh(uint64_t start_height, size_t & blocks_fetched, bool& rece LOG_PRINT_L1("Refresh done, blocks received: " << blocks_fetched << ", balance: " << print_money(balance()) << ", unlocked: " << print_money(unlocked_balance())); } //---------------------------------------------------------------------------------------------------- -bool wallet2::refresh(size_t & blocks_fetched, bool& received_money, bool& ok) +bool wallet2::refresh(uint64_t & blocks_fetched, bool& received_money, bool& ok) { try { diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index a8c7f9b78..91c2cf094 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -213,9 +213,9 @@ namespace tools */ bool is_deprecated() const; void refresh(); - void refresh(uint64_t start_height, size_t & blocks_fetched); - void refresh(uint64_t start_height, size_t & blocks_fetched, bool& received_money); - bool refresh(size_t & blocks_fetched, bool& received_money, bool& ok); + void refresh(uint64_t start_height, uint64_t & blocks_fetched); + void refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& received_money); + bool refresh(uint64_t & blocks_fetched, bool& received_money, bool& ok); bool testnet() const { return m_testnet; } bool restricted() const { return m_restricted; } @@ -318,7 +318,7 @@ namespace tools bool is_tx_spendtime_unlocked(uint64_t unlock_time) const; bool is_transfer_unlocked(const transfer_details& td) const; bool clear(); - void pull_blocks(uint64_t start_height, size_t& blocks_added); + void pull_blocks(uint64_t start_height, uint64_t& blocks_added); uint64_t select_transfers(uint64_t needed_money, bool add_dust, uint64_t dust, std::list<transfer_container::iterator>& selected_transfers); bool prepare_file_names(const std::string& file_path); void process_unconfirmed(const cryptonote::transaction& tx); diff --git a/tests/unit_tests/hardfork.cpp b/tests/unit_tests/hardfork.cpp index 5c58b3f4b..f7e4f27e9 100644 --- a/tests/unit_tests/hardfork.cpp +++ b/tests/unit_tests/hardfork.cpp @@ -81,7 +81,6 @@ public: virtual uint64_t get_num_outputs(const uint64_t& amount) const { return 1; } virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index) { return output_data_t(); } virtual output_data_t get_output_key(const uint64_t& global_index) const { return output_data_t(); } - virtual tx_out get_output(const crypto::hash& h, const uint64_t& index) const { return tx_out(); } virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const { return tx_out_index(); } virtual tx_out_index get_output_tx_and_index(const uint64_t& amount, const uint64_t& index) { return tx_out_index(); } virtual void get_output_tx_and_index(const uint64_t& amount, const std::vector<uint64_t> &offsets, std::vector<tx_out_index> &indices) {} |