Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
lmdb_transaction.cpp
Go to the documentation of this file.
4#include <cstdint>
5#include <utility>
6
7namespace bb::lmdblib {
8LMDBTransaction::LMDBTransaction(std::shared_ptr<LMDBEnvironment> env, bool readOnly)
9 : _environment(std::move(env))
10 , _id(_environment->getNextId())
11 , state(TransactionState::OPEN)
12{
13 MDB_txn* p = nullptr;
14 const std::string name("mdb_txn_begin");
15 call_lmdb_func(name, mdb_txn_begin, _environment->underlying(), p, readOnly ? MDB_RDONLY : 0U, &_transaction);
16}
17
18LMDBTransaction::~LMDBTransaction() = default;
19
20MDB_txn* LMDBTransaction::underlying() const
21{
22 return _transaction;
23}
24
25uint64_t LMDBTransaction::id() const
26{
27 return _id;
28}
29
30void LMDBTransaction::abort()
31{
32 if (state != TransactionState::OPEN) {
33 return;
34 }
35 call_lmdb_func(mdb_txn_abort, _transaction);
36 state = TransactionState::ABORTED;
37}
38
39bool LMDBTransaction::get_value(std::vector<uint8_t>& key, std::vector<uint8_t>& data, const LMDBDatabase& db) const
40{
41 return lmdb_queries::get_value(key, data, db, *this);
42}
43
44bool LMDBTransaction::get_value(std::vector<uint8_t>& key, uint64_t& data, const LMDBDatabase& db) const
45{
46 return lmdb_queries::get_value(key, data, db, *this);
47}
48} // namespace bb::lmdblib
LMDBTransaction(LMDBEnvironment::SharedPtr env, bool readOnly=false)
const std::vector< FF > data
bool call_lmdb_func(int(*f)(TArgs...), TArgs... args)
STL namespace.