Merge pull request #460

4f873bc Remove some old/obsolete/unused code (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2015-10-30 09:58:40 +02:00
commit 6960b1e8a9
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD
8 changed files with 0 additions and 221 deletions

View file

@ -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__);

View file

@ -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,

View file

@ -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;

View file

@ -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__);

View file

@ -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;

View file

@ -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__);

View file

@ -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)

View file

@ -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) {}