|
|
|
@ -553,7 +553,7 @@ uint64_t BlockchainLMDB::get_output_global_index(const uint64_t& amount, const u
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -665,7 +665,7 @@ void BlockchainLMDB::open(const std::string& filename)
|
|
|
|
|
throw0(DB_ERROR(std::string("Failed to open lmdb environment: ").append(mdb_strerror(result)).c_str()));
|
|
|
|
|
|
|
|
|
|
// get a read/write MDB_txn
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
if (mdb_txn_begin(m_env, NULL, 0, txn))
|
|
|
|
|
throw0(DB_ERROR("Failed to create a transaction for the db"));
|
|
|
|
|
|
|
|
|
@ -802,7 +802,7 @@ bool BlockchainLMDB::block_exists(const crypto::hash& h) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -835,7 +835,7 @@ uint64_t BlockchainLMDB::get_block_height(const crypto::hash& h) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -865,7 +865,7 @@ block BlockchainLMDB::get_block_from_height(const uint64_t& height) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -896,8 +896,8 @@ uint64_t BlockchainLMDB::get_block_timestamp(const uint64_t& height) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -939,8 +939,8 @@ size_t BlockchainLMDB::get_block_size(const uint64_t& height) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -969,8 +969,8 @@ difficulty_type BlockchainLMDB::get_block_cumulative_difficulty(const uint64_t&
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__ << " height: " << height);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -1015,8 +1015,8 @@ uint64_t BlockchainLMDB::get_block_already_generated_coins(const uint64_t& heigh
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -1045,8 +1045,8 @@ crypto::hash BlockchainLMDB::get_block_hash_from_height(const uint64_t& height)
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -1138,8 +1138,8 @@ bool BlockchainLMDB::tx_exists(const crypto::hash& h) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -1173,7 +1173,7 @@ uint64_t BlockchainLMDB::get_tx_unlock_time(const crypto::hash& h) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1193,8 +1193,8 @@ transaction BlockchainLMDB::get_tx(const crypto::hash& h) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -1228,7 +1228,7 @@ uint64_t BlockchainLMDB::get_tx_count() const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1268,8 +1268,8 @@ uint64_t BlockchainLMDB::get_tx_block_height(const crypto::hash& h) const
|
|
|
|
|
// read transaction here, as validation is done prior to the write for block
|
|
|
|
|
// and tx data.
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -1312,7 +1312,7 @@ uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1343,7 +1343,7 @@ crypto::public_key BlockchainLMDB::get_output_key(const uint64_t& amount, const
|
|
|
|
|
|
|
|
|
|
uint64_t glob_index = get_output_global_index(amount, index);
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1363,7 +1363,7 @@ tx_out BlockchainLMDB::get_output(const crypto::hash& h, const uint64_t& index)
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1408,7 +1408,7 @@ tx_out BlockchainLMDB::get_output(const uint64_t& index) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1432,8 +1432,8 @@ tx_out_index BlockchainLMDB::get_output_tx_and_index_from_global(const uint64_t&
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -1468,8 +1468,8 @@ tx_out_index BlockchainLMDB::get_output_tx_and_index(const uint64_t& amount, con
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
txn_safe* txn_ptr = &txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
mdb_txn_safe* txn_ptr = &txn;
|
|
|
|
|
if (m_batch_active)
|
|
|
|
|
txn_ptr = m_write_txn;
|
|
|
|
|
else
|
|
|
|
@ -1518,7 +1518,7 @@ std::vector<uint64_t> BlockchainLMDB::get_tx_output_indices(const crypto::hash&
|
|
|
|
|
check_open();
|
|
|
|
|
std::vector<uint64_t> index_vec;
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1563,7 +1563,7 @@ std::vector<uint64_t> BlockchainLMDB::get_tx_amount_output_indices(const crypto:
|
|
|
|
|
|
|
|
|
|
transaction tx = get_tx(h);
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1634,7 +1634,7 @@ bool BlockchainLMDB::has_key_image(const crypto::key_image& img) const
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
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"));
|
|
|
|
|
|
|
|
|
@ -1745,7 +1745,7 @@ uint64_t BlockchainLMDB::add_block( const block& blk
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
if (! m_batch_active)
|
|
|
|
|
{
|
|
|
|
|
if (mdb_txn_begin(m_env, NULL, 0, txn))
|
|
|
|
@ -1783,7 +1783,7 @@ void BlockchainLMDB::pop_block(block& blk, std::vector<transaction>& txs)
|
|
|
|
|
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
|
|
|
|
|
check_open();
|
|
|
|
|
|
|
|
|
|
txn_safe txn;
|
|
|
|
|
mdb_txn_safe txn;
|
|
|
|
|
if (! m_batch_active)
|
|
|
|
|
{
|
|
|
|
|
if (mdb_txn_begin(m_env, NULL, 0, txn))
|
|
|
|
|