diff options
author | warptangent <warptangent@inbox.com> | 2015-05-16 01:29:02 -0700 |
---|---|---|
committer | warptangent <warptangent@inbox.com> | 2015-05-16 01:34:58 -0700 |
commit | d35bffb950d7cdfc24c72ef098c3018befad14d6 (patch) | |
tree | a1a2a567dc2a224227a98a683624bd28ea837910 /src/blockchain_db | |
parent | Rename "--block-number" option to "--block-stop" (diff) | |
download | monero-d35bffb950d7cdfc24c72ef098c3018befad14d6.tar.xz |
Allow BlockchainLMDB to be opened in read-only mode
Have blockchain_export use read-only mode when source is BlockchainLMDB.
Diffstat (limited to 'src/blockchain_db')
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 5126db400..201386e47 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -678,9 +678,13 @@ void BlockchainLMDB::open(const std::string& filename, const int mdb_flags) if (auto result = mdb_env_open(m_env, filename.c_str(), mdb_flags, 0644)) throw0(DB_ERROR(std::string("Failed to open lmdb environment: ").append(mdb_strerror(result)).c_str())); - // get a read/write MDB_txn + int txn_flags = 0; + if (mdb_flags & MDB_RDONLY) + txn_flags |= MDB_RDONLY; + + // get a read/write MDB_txn, depending on mdb_flags mdb_txn_safe txn; - if (mdb_txn_begin(m_env, NULL, 0, txn)) + if (mdb_txn_begin(m_env, NULL, txn_flags, txn)) throw0(DB_ERROR("Failed to create a transaction for the db")); // open necessary databases, and set properties as needed |