aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
Diffstat (limited to 'src/blockchain_db')
-rw-r--r--src/blockchain_db/berkeleydb/db_bdb.h2
-rw-r--r--src/blockchain_db/blockchain_db.cpp4
-rw-r--r--src/blockchain_db/blockchain_db.h17
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp68
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h1
5 files changed, 18 insertions, 74 deletions
diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h
index c90d030a2..8c99ab255 100644
--- a/src/blockchain_db/berkeleydb/db_bdb.h
+++ b/src/blockchain_db/berkeleydb/db_bdb.h
@@ -303,7 +303,6 @@ public:
virtual uint64_t get_indexing_base() const { return 1; }
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_index get_output_tx_and_index_from_global(const uint64_t& index) const;
@@ -419,6 +418,7 @@ private:
* @return the global index of the desired output
*/
uint64_t get_output_global_index(const uint64_t& amount, const uint64_t& index);
+ output_data_t get_output_key(const uint64_t& global_index) const;
void checkpoint_worker() const;
void check_open() const;
diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp
index 8544cc3f0..78d63fdcf 100644
--- a/src/blockchain_db/blockchain_db.cpp
+++ b/src/blockchain_db/blockchain_db.cpp
@@ -87,8 +87,8 @@ const command_line::arg_descriptor<std::string> arg_db_type = {
};
const command_line::arg_descriptor<std::string> arg_db_sync_mode = {
"db-sync-mode"
-, "Specify sync option, using format [safe|fast|fastest]:[sync|async]:[nblocks_per_sync]."
-, "fast:async:1000"
+, "Specify sync option, using format [safe|fast|fastest]:[sync|async]:[<nblocks_per_sync>[blocks]|<nbytes_per_sync>[bytes]]."
+, "fast:async:250000000bytes"
};
const command_line::arg_descriptor<bool> arg_db_salvage = {
"db-salvage"
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index 6851e2404..4431ca44c 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -1262,23 +1262,6 @@ public:
virtual output_data_t get_output_key(const uint64_t& amount, const uint64_t& index) = 0;
/**
- * @brief get some of an output's data
- *
- * The subclass should return the public key, unlock time, and block height
- * for the output with the given global index, collected in a struct.
- *
- * If the output cannot be found, the subclass should throw OUTPUT_DNE.
- *
- * If any of these parts cannot be found, but some are, the subclass
- * should throw DB_ERROR with a message stating as much.
- *
- * @param global_index the output's index (global)
- *
- * @return the requested output data
- */
- virtual output_data_t get_output_key(const uint64_t& global_index) const = 0;
-
- /**
* @brief gets an output's tx hash and index
*
* The subclass should return the hash of the transaction which created the
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index f45b9eff1..7e54041d7 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -1967,14 +1967,25 @@ std::vector<uint64_t> BlockchainLMDB::get_block_cumulative_rct_outputs(const std
MDB_val v;
+ uint64_t prev_height = heights[0];
for (uint64_t height: heights)
{
- MDB_val_set(v, height);
- result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &v, MDB_GET_BOTH);
+ if (height == prev_height + 1)
+ {
+ MDB_val k2;
+ result = mdb_cursor_get(m_cur_block_info, &k2, &v, MDB_NEXT);
+ }
+ else
+ {
+ v.mv_size = sizeof(uint64_t);
+ v.mv_data = (void*)&height;
+ result = mdb_cursor_get(m_cur_block_info, (MDB_val *)&zerokval, &v, MDB_GET_BOTH);
+ }
if (result)
throw0(DB_ERROR(lmdb_error("Error attempting to retrieve rct distribution from the db: ", result).c_str()));
const mdb_block_info *bi = (const mdb_block_info *)v.mv_data;
res.push_back(bi->bi_cum_rct);
+ prev_height = height;
}
TXN_POSTFIX_RDONLY();
@@ -2450,55 +2461,6 @@ uint64_t BlockchainLMDB::get_num_outputs(const uint64_t& amount) const
return num_elems;
}
-// This is a lot harder now that we've removed the output_keys index
-output_data_t BlockchainLMDB::get_output_key(const uint64_t &global_index) const
-{
- LOG_PRINT_L3("BlockchainLMDB::" << __func__ << " (unused version - does nothing)");
- check_open();
- TXN_PREFIX_RDONLY();
- RCURSOR(output_txs);
- RCURSOR(tx_indices);
-
- output_data_t od;
- MDB_val_set(v, global_index);
- auto get_result = mdb_cursor_get(m_cur_output_txs, (MDB_val *)&zerokval, &v, MDB_GET_BOTH);
- if (get_result == MDB_NOTFOUND)
- throw1(OUTPUT_DNE("output with given index not in db"));
- else if (get_result)
- throw0(DB_ERROR("DB error attempting to fetch output tx hash"));
-
- outtx *ot = (outtx *)v.mv_data;
-
- MDB_val_set(val_h, ot->tx_hash);
- get_result = mdb_cursor_get(m_cur_tx_indices, (MDB_val *)&zerokval, &val_h, MDB_GET_BOTH);
- if (get_result)
- throw0(DB_ERROR(lmdb_error(std::string("DB error attempting to fetch transaction index from hash ") + epee::string_tools::pod_to_hex(ot->tx_hash) + ": ", get_result).c_str()));
-
- txindex *tip = (txindex *)val_h.mv_data;
- MDB_val_set(val_tx_id, tip->data.tx_id);
- MDB_val result;
- get_result = mdb_cursor_get(m_cur_txs_pruned, &val_tx_id, &result, MDB_SET);
- if (get_result == MDB_NOTFOUND)
- throw1(TX_DNE(std::string("tx with hash ").append(epee::string_tools::pod_to_hex(ot->tx_hash)).append(" not found in db").c_str()));
- else if (get_result)
- throw0(DB_ERROR(lmdb_error("DB error attempting to fetch tx from hash", get_result).c_str()));
-
- blobdata bd;
- bd.assign(reinterpret_cast<char*>(result.mv_data), result.mv_size);
-
- transaction tx;
- if (!parse_and_validate_tx_base_from_blob(bd, tx))
- throw0(DB_ERROR("Failed to parse tx from blob retrieved from the db"));
-
- const tx_out tx_output = tx.vout[ot->local_index];
- od.unlock_time = tip->data.unlock_time;
- od.height = tip->data.block_id;
- od.pubkey = boost::get<txout_to_key>(tx_output.target).key;
-
- TXN_POSTFIX_RDONLY();
- return od;
-}
-
output_data_t BlockchainLMDB::get_output_key(const uint64_t& amount, const uint64_t& index)
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
@@ -2981,10 +2943,10 @@ void BlockchainLMDB::set_batch_transactions(bool batch_transactions)
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
if ((batch_transactions) && (m_batch_transactions))
{
- LOG_PRINT_L0("WARNING: batch transaction mode already enabled, but asked to enable batch mode");
+ MINFO("batch transaction mode already enabled, but asked to enable batch mode");
}
m_batch_transactions = batch_transactions;
- LOG_PRINT_L3("batch transactions " << (m_batch_transactions ? "enabled" : "disabled"));
+ MINFO("batch transactions " << (m_batch_transactions ? "enabled" : "disabled"));
}
// return true if we started the txn, false if already started
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index 5e3b3cfa5..f700d3178 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -243,7 +243,6 @@ 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, bool allow_partial = false);
virtual tx_out_index get_output_tx_and_index_from_global(const uint64_t& index) const;