mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
Merge pull request #338
71793ef
Add batch support to BlockchainLMDB::get_output_key (warptangent)
This commit is contained in:
commit
5de12913dc
1 changed files with 12 additions and 6 deletions
|
@ -2294,15 +2294,20 @@ void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<ui
|
||||||
if (global_indices.size() > 0)
|
if (global_indices.size() > 0)
|
||||||
{
|
{
|
||||||
mdb_txn_safe txn;
|
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))
|
if (mdb_txn_begin(m_env, NULL, MDB_RDONLY, txn))
|
||||||
throw0(DB_ERROR("Failed to create a transaction for the db"));
|
throw0(DB_ERROR("Failed to create a transaction for the db"));
|
||||||
|
}
|
||||||
for (const uint64_t &index : global_indices)
|
for (const uint64_t &index : global_indices)
|
||||||
{
|
{
|
||||||
MDB_val_copy<uint64_t> k(index);
|
MDB_val_copy<uint64_t> k(index);
|
||||||
MDB_val v;
|
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)
|
if (get_result != 0)
|
||||||
throw0(DB_ERROR("Attempting to get output pubkey by global index, but key does not exist"));
|
throw0(DB_ERROR("Attempting to get output pubkey by global index, but key does not exist"));
|
||||||
else if (get_result)
|
else if (get_result)
|
||||||
|
@ -2312,6 +2317,7 @@ void BlockchainLMDB::get_output_key(const uint64_t &amount, const std::vector<ui
|
||||||
outputs.push_back(data);
|
outputs.push_back(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m_batch_active)
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue