mirror of
https://github.com/monero-project/monero.git
synced 2025-01-28 18:56:31 +02:00
Merge pull request #516
76230fe
gcc warning/error flags to fix compilation (Thomas Winget)cc3394b
Update BlockchainDB documentation (Thomas Winget)204ed98
Rename function for clarity (Thomas Winget)
This commit is contained in:
commit
59e0db15dd
@ -293,6 +293,7 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
set(WARNINGS "-Wall -Wextra -Wpointer-arith -Wundef -Wvla -Wwrite-strings -Wno-error=extra -Wno-error=deprecated-declarations -Wno-error=sign-compare -Wno-error=strict-aliasing -Wno-error=type-limits -Wno-unused-parameter -Wno-error=unused-variable -Wno-error=undef -Wno-error=uninitialized")
|
||||
set(WARNINGS "${WARNINGS} -Wno-error=unused-function -Wno-error=logical-not-parentheses")
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(WARNINGS "${WARNINGS} -Wno-deprecated-register")
|
||||
endif()
|
||||
|
@ -388,7 +388,7 @@ void BlockchainBDB::add_output(const crypto::hash& tx_hash, const tx_out& tx_out
|
||||
od.height = m_height;
|
||||
|
||||
Dbt_copy<output_data_t> data(od);
|
||||
if (m_output_keys->put(DB_DEFAULT_TX, &k, &data, 0))
|
||||
if (m_output_data->put(DB_DEFAULT_TX, &k, &data, 0))
|
||||
throw0(DB_ERROR("Failed to add output pubkey to db transaction"));
|
||||
}
|
||||
|
||||
@ -468,10 +468,10 @@ void BlockchainBDB::remove_output(const uint64_t& out_index, const uint64_t amou
|
||||
throw1(DB_ERROR("Error adding removal of output tx hash to db transaction"));
|
||||
}
|
||||
|
||||
result = m_output_keys->del(DB_DEFAULT_TX, &k, 0);
|
||||
result = m_output_data->del(DB_DEFAULT_TX, &k, 0);
|
||||
if (result == DB_NOTFOUND)
|
||||
{
|
||||
LOG_PRINT_L0("Unexpected: global output index not found in m_output_keys");
|
||||
LOG_PRINT_L0("Unexpected: global output index not found in m_output_data");
|
||||
}
|
||||
else if (result)
|
||||
throw1(DB_ERROR("Error adding removal of output pubkey to db transaction"));
|
||||
@ -808,7 +808,7 @@ void BlockchainBDB::open(const std::string& filename, const int db_flags)
|
||||
m_output_txs = new Db(m_env, 0);
|
||||
m_output_indices = new Db(m_env, 0);
|
||||
m_output_amounts = new Db(m_env, 0);
|
||||
m_output_keys = new Db(m_env, 0);
|
||||
m_output_data = new Db(m_env, 0);
|
||||
|
||||
m_spent_keys = new Db(m_env, 0);
|
||||
|
||||
@ -832,7 +832,7 @@ void BlockchainBDB::open(const std::string& filename, const int db_flags)
|
||||
|
||||
m_output_txs->set_re_len(sizeof(crypto::hash));
|
||||
m_output_indices->set_re_len(sizeof(uint64_t));
|
||||
m_output_keys->set_re_len(sizeof(output_data_t));
|
||||
m_output_data->set_re_len(sizeof(output_data_t));
|
||||
|
||||
m_hf_starting_heights->set_re_len(sizeof(uint64_t));
|
||||
m_hf_versions->set_re_len(sizeof(uint8_t));
|
||||
@ -862,7 +862,7 @@ void BlockchainBDB::open(const std::string& filename, const int db_flags)
|
||||
m_output_txs->open(txn, BDB_OUTPUT_TXS, NULL, DB_RECNO, DB_CREATE, 0);
|
||||
m_output_indices->open(txn, BDB_OUTPUT_INDICES, NULL, DB_RECNO, DB_CREATE, 0);
|
||||
m_output_amounts->open(txn, BDB_OUTPUT_AMOUNTS, NULL, DB_HASH, DB_CREATE, 0);
|
||||
m_output_keys->open(txn, BDB_OUTPUT_KEYS, NULL, DB_RECNO, DB_CREATE, 0);
|
||||
m_output_data->open(txn, BDB_OUTPUT_KEYS, NULL, DB_RECNO, DB_CREATE, 0);
|
||||
|
||||
m_spent_keys->open(txn, BDB_SPENT_KEYS, NULL, DB_HASH, DB_CREATE, 0);
|
||||
|
||||
@ -990,7 +990,7 @@ void BlockchainBDB::sync()
|
||||
m_output_txs->sync(0);
|
||||
m_output_indices->sync(0);
|
||||
m_output_amounts->sync(0);
|
||||
m_output_keys->sync(0);
|
||||
m_output_data->sync(0);
|
||||
|
||||
m_spent_keys->sync(0);
|
||||
|
||||
@ -1066,7 +1066,7 @@ std::vector<std::string> BlockchainBDB::get_filenames() const
|
||||
m_output_amounts->get_dbname(pfname, pdbname);
|
||||
filenames.push_back(fname);
|
||||
|
||||
m_output_keys->get_dbname(pfname, pdbname);
|
||||
m_output_data->get_dbname(pfname, pdbname);
|
||||
filenames.push_back(fname);
|
||||
|
||||
m_spent_keys->get_dbname(pfname, pdbname);
|
||||
@ -1511,14 +1511,14 @@ uint64_t BlockchainBDB::get_num_outputs(const uint64_t& amount) const
|
||||
return num_elems;
|
||||
}
|
||||
|
||||
output_data_t BlockchainBDB::get_output_key(const uint64_t& global_index) const
|
||||
output_data_t BlockchainBDB::get_output_data(const uint64_t& global_index) const
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainBDB::" << __func__);
|
||||
check_open();
|
||||
|
||||
Dbt_copy<uint32_t> k(global_index);
|
||||
Dbt_copy<output_data_t> v;
|
||||
auto get_result = m_output_keys->get(DB_DEFAULT_TX, &k, &v, 0);
|
||||
auto get_result = m_output_data->get(DB_DEFAULT_TX, &k, &v, 0);
|
||||
if (get_result == DB_NOTFOUND)
|
||||
throw1(OUTPUT_DNE("Attempting to get output pubkey by global index, but key does not exist"));
|
||||
else if (get_result)
|
||||
@ -1527,13 +1527,13 @@ output_data_t BlockchainBDB::get_output_key(const uint64_t& global_index) const
|
||||
return v;
|
||||
}
|
||||
|
||||
output_data_t BlockchainBDB::get_output_key(const uint64_t& amount, const uint64_t& index)
|
||||
output_data_t BlockchainBDB::get_output_data(const uint64_t& amount, const uint64_t& index)
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainBDB::" << __func__);
|
||||
check_open();
|
||||
|
||||
uint64_t glob_index = get_output_global_index(amount, index);
|
||||
return get_output_key(glob_index);
|
||||
return get_output_data(glob_index);
|
||||
}
|
||||
|
||||
tx_out_index BlockchainBDB::get_output_tx_and_index(const uint64_t& amount, const uint64_t& index)
|
||||
@ -1996,7 +1996,7 @@ void BlockchainBDB::get_output_global_indices(const uint64_t& amount, const std:
|
||||
|
||||
}
|
||||
|
||||
void BlockchainBDB::get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs)
|
||||
void BlockchainBDB::get_output_data(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs)
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainBDB::" << __func__);
|
||||
check_open();
|
||||
@ -2014,7 +2014,7 @@ void BlockchainBDB::get_output_key(const uint64_t &amount, const std::vector<uin
|
||||
Dbt_copy<uint32_t> k(index);
|
||||
Dbt_copy<output_data_t> v;
|
||||
|
||||
auto get_result = m_output_keys->get(DB_DEFAULT_TX, &k, &v, 0);
|
||||
auto get_result = m_output_data->get(DB_DEFAULT_TX, &k, &v, 0);
|
||||
if (get_result == DB_NOTFOUND)
|
||||
throw1(OUTPUT_DNE("output with given index not in db"));
|
||||
else if (get_result)
|
||||
|
@ -297,9 +297,9 @@ public:
|
||||
|
||||
virtual uint64_t get_num_outputs(const uint64_t& amount) const;
|
||||
|
||||
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 output_data_t get_output_data(const uint64_t& amount, const uint64_t& index);
|
||||
virtual output_data_t get_output_data(const uint64_t& global_index) const;
|
||||
virtual void get_output_data(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs);
|
||||
|
||||
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,
|
||||
@ -426,7 +426,7 @@ private:
|
||||
Db* m_output_txs;
|
||||
Db* m_output_indices;
|
||||
Db* m_output_amounts;
|
||||
Db* m_output_keys;
|
||||
Db* m_output_data;
|
||||
|
||||
Db* m_spent_keys;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -685,7 +685,7 @@ void BlockchainLMDB::add_output(const crypto::hash& tx_hash, const tx_out& tx_ou
|
||||
|
||||
MDB_val_copy<output_data_t> data(od);
|
||||
//MDB_val_copy<crypto::public_key> val_pubkey(boost::get<txout_to_key>(tx_output.target).key);
|
||||
if (mdb_put(*m_write_txn, m_output_keys, &k, &data, 0))
|
||||
if (mdb_put(*m_write_txn, m_output_data, &k, &data, 0))
|
||||
throw0(DB_ERROR("Failed to add output pubkey to db transaction"));
|
||||
}
|
||||
|
||||
@ -767,10 +767,10 @@ void BlockchainLMDB::remove_output(const uint64_t& out_index, const uint64_t amo
|
||||
throw1(DB_ERROR("Error adding removal of output tx hash to db transaction"));
|
||||
}
|
||||
|
||||
result = mdb_del(*m_write_txn, m_output_keys, &k, NULL);
|
||||
result = mdb_del(*m_write_txn, m_output_data, &k, NULL);
|
||||
if (result == MDB_NOTFOUND)
|
||||
{
|
||||
LOG_PRINT_L0("Unexpected: global output index not found in m_output_keys");
|
||||
LOG_PRINT_L0("Unexpected: global output index not found in m_output_data");
|
||||
}
|
||||
else if (result)
|
||||
throw1(DB_ERROR("Error adding removal of output pubkey to db transaction"));
|
||||
@ -1016,7 +1016,7 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags)
|
||||
lmdb_db_open(txn, LMDB_OUTPUT_TXS, MDB_INTEGERKEY | MDB_CREATE, m_output_txs, "Failed to open db handle for m_output_txs");
|
||||
lmdb_db_open(txn, LMDB_OUTPUT_INDICES, MDB_INTEGERKEY | MDB_CREATE, m_output_indices, "Failed to open db handle for m_output_indices");
|
||||
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");
|
||||
lmdb_db_open(txn, LMDB_OUTPUT_KEYS, MDB_INTEGERKEY | MDB_CREATE, m_output_data, "Failed to open db handle for m_output_data");
|
||||
|
||||
lmdb_db_open(txn, LMDB_SPENT_KEYS, MDB_CREATE, m_spent_keys, "Failed to open db handle for m_spent_keys");
|
||||
|
||||
@ -1058,7 +1058,7 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags)
|
||||
{
|
||||
MDB_val_copy<uint64_t> k(0);
|
||||
MDB_val v;
|
||||
auto get_result = mdb_get(txn, m_output_keys, &k, &v);
|
||||
auto get_result = mdb_get(txn, m_output_data, &k, &v);
|
||||
if(get_result != MDB_SUCCESS)
|
||||
{
|
||||
txn.abort();
|
||||
@ -1718,7 +1718,7 @@ uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) const
|
||||
return num_elems;
|
||||
}
|
||||
|
||||
output_data_t BlockchainLMDB::get_output_key(const uint64_t &global_index) const
|
||||
output_data_t BlockchainLMDB::get_output_data(const uint64_t &global_index) const
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
check_open();
|
||||
@ -1729,7 +1729,7 @@ output_data_t BlockchainLMDB::get_output_key(const uint64_t &global_index) const
|
||||
|
||||
MDB_val_copy<uint64_t> k(global_index);
|
||||
MDB_val v;
|
||||
auto get_result = mdb_get(txn, m_output_keys, &k, &v);
|
||||
auto get_result = mdb_get(txn, m_output_data, &k, &v);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
throw1(OUTPUT_DNE("Attempting to get output pubkey by global index, but key does not exist"));
|
||||
else if (get_result)
|
||||
@ -1738,13 +1738,13 @@ output_data_t BlockchainLMDB::get_output_key(const uint64_t &global_index) const
|
||||
return *(output_data_t *) v.mv_data;
|
||||
}
|
||||
|
||||
output_data_t BlockchainLMDB::get_output_key(const uint64_t& amount, const uint64_t& index)
|
||||
output_data_t BlockchainLMDB::get_output_data(const uint64_t& amount, const uint64_t& index)
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
check_open();
|
||||
|
||||
uint64_t glob_index = get_output_global_index(amount, index);
|
||||
return get_output_key(glob_index);
|
||||
return get_output_data(glob_index);
|
||||
}
|
||||
|
||||
tx_out_index BlockchainLMDB::get_output_tx_and_index_from_global(const uint64_t& index) const
|
||||
@ -2427,7 +2427,7 @@ void BlockchainLMDB::get_output_global_indices(const uint64_t& amount, const std
|
||||
LOG_PRINT_L3("txx: " << txx << " db1: " << t_dbmul << " db2: " << t_dbscan);
|
||||
}
|
||||
|
||||
void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs)
|
||||
void BlockchainLMDB::get_output_data(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs)
|
||||
{
|
||||
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
||||
TIME_MEASURE_START(db3);
|
||||
@ -2453,7 +2453,7 @@ void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<ui
|
||||
MDB_val_copy<uint64_t> k(index);
|
||||
MDB_val v;
|
||||
|
||||
auto get_result = mdb_get(*txn_ptr, m_output_keys, &k, &v);
|
||||
auto get_result = mdb_get(*txn_ptr, m_output_data, &k, &v);
|
||||
if (get_result == MDB_NOTFOUND)
|
||||
throw1(OUTPUT_DNE("Attempting to get output pubkey by global index, but key does not exist"));
|
||||
else if (get_result)
|
||||
|
@ -159,9 +159,9 @@ public:
|
||||
|
||||
virtual uint64_t get_num_outputs(const uint64_t& amount) const;
|
||||
|
||||
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 output_data_t get_output_data(const uint64_t& amount, const uint64_t& index);
|
||||
virtual output_data_t get_output_data(const uint64_t& global_index) const;
|
||||
virtual void get_output_data(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs);
|
||||
|
||||
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,
|
||||
@ -284,7 +284,7 @@ private:
|
||||
MDB_dbi m_output_txs;
|
||||
MDB_dbi m_output_indices;
|
||||
MDB_dbi m_output_amounts;
|
||||
MDB_dbi m_output_keys;
|
||||
MDB_dbi m_output_data;
|
||||
|
||||
MDB_dbi m_spent_keys;
|
||||
|
||||
|
@ -406,7 +406,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
try
|
||||
{
|
||||
output_data_t od = db->get_output_key(idx);
|
||||
output_data_t od = db->get_output_data(idx);
|
||||
start_struct(d, boost::lexical_cast<std::string>(idx));
|
||||
write_pod(d, "pubkey", string_tools::pod_to_hex(od.pubkey));
|
||||
write_pod(d, "unlock_time", od.unlock_time);
|
||||
|
@ -152,7 +152,7 @@ bool Blockchain::scan_outputkeys_for_indexes(const txin_to_key& tx_in_to_key, vi
|
||||
|
||||
if (!found)
|
||||
{
|
||||
m_db->get_output_key(tx_in_to_key.amount, absolute_offsets, outputs);
|
||||
m_db->get_output_data(tx_in_to_key.amount, absolute_offsets, outputs);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -164,7 +164,7 @@ bool Blockchain::scan_outputkeys_for_indexes(const txin_to_key& tx_in_to_key, vi
|
||||
std::vector<output_data_t> add_outputs;
|
||||
for (size_t i = outputs.size(); i < absolute_offsets.size(); i++)
|
||||
add_offsets.push_back(absolute_offsets[i]);
|
||||
m_db->get_output_key(tx_in_to_key.amount, add_offsets, add_outputs);
|
||||
m_db->get_output_data(tx_in_to_key.amount, add_offsets, add_outputs);
|
||||
outputs.insert(outputs.end(), add_outputs.begin(), add_outputs.end());
|
||||
}
|
||||
}
|
||||
@ -181,7 +181,7 @@ bool Blockchain::scan_outputkeys_for_indexes(const txin_to_key& tx_in_to_key, vi
|
||||
if (count < outputs.size())
|
||||
output_index = outputs.at(count);
|
||||
else
|
||||
output_index = m_db->get_output_key(tx_in_to_key.amount, i);
|
||||
output_index = m_db->get_output_data(tx_in_to_key.amount, i);
|
||||
|
||||
// call to the passed boost visitor to grab the public key for the output
|
||||
if (!vis.handle_output(output_index.unlock_time, output_index.pubkey))
|
||||
@ -1409,7 +1409,7 @@ void Blockchain::add_out_to_get_random_outs(COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_A
|
||||
|
||||
COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::out_entry& oen = *result_outs.outs.insert(result_outs.outs.end(), COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::out_entry());
|
||||
oen.global_amount_index = i;
|
||||
output_data_t data = m_db->get_output_key(amount, i);
|
||||
output_data_t data = m_db->get_output_data(amount, i);
|
||||
oen.out_key = data.pubkey;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
@ -2828,7 +2828,7 @@ void Blockchain::output_scan_worker(const uint64_t amount, const std::vector<uin
|
||||
{
|
||||
try
|
||||
{
|
||||
m_db->get_output_key(amount, offsets, outputs);
|
||||
m_db->get_output_data(amount, offsets, outputs);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user