diff options
author | Riccardo Spagni <ric@spagni.net> | 2015-07-16 09:44:55 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2015-07-16 09:45:07 +0200 |
commit | 5de12913dc28a10e0c79afaba0bda78e4a0fdfb3 (patch) | |
tree | 68d80433ea511086e556c3b7b41ee68c45752ca7 | |
parent | Removed on_idle() calls to Blockchain::store_blockchain() for lmdb. (diff) | |
parent | Add batch support to BlockchainLMDB::get_output_key (diff) | |
download | monero-5de12913dc28a10e0c79afaba0bda78e4a0fdfb3.tar.xz |
Merge pull request #338
71793ef Add batch support to BlockchainLMDB::get_output_key (warptangent)
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 63ac54171..dd829f3b0 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -2293,16 +2293,21 @@ void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<ui if (global_indices.size() > 0) { - 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_txn_safe txn; + mdb_txn_safe* txn_ptr = &txn; + if (m_batch_active) + txn_ptr = m_write_txn; + else + { + if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn)) + throw0(DB_ERROR("Failed to create a transaction for the db")); + } for (const uint64_t &index : global_indices) { MDB_val_copy<uint64_t> k(index); MDB_val v; - auto get_result = mdb_get(txn, m_output_keys, &k, &v); + auto get_result = mdb_get(*txn_ptr, m_output_keys, &k, &v); if (get_result != 0) throw0(DB_ERROR("Attempting to get output pubkey by global index, but key does not exist")); else if (get_result) @@ -2312,7 +2317,8 @@ void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<ui outputs.push_back(data); } - txn.commit(); + if (!m_batch_active) + txn.commit(); } TIME_MEASURE_FINISH(db3); |