diff options
author | luigi1111 <luigi1111w@gmail.com> | 2018-05-31 14:41:17 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2018-05-31 14:41:17 -0500 |
commit | b6eb7484d1f8b7055a20f116b07a0787019e2be7 (patch) | |
tree | 884cec37eb1760515b89602afe0188c05e697b46 /src/wallet | |
parent | Merge pull request #3583 (diff) | |
parent | unit_tests: add ringdb unit tests (diff) | |
download | monero-b6eb7484d1f8b7055a20f116b07a0787019e2be7.tar.xz |
Merge pull request #3592
90a16b1 crypto: fix initialization order issue with random mutex (moneromooo-monero)
6a61f52 unit_tests: add ringdb unit tests (moneromooo-monero)
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/ringdb.cpp | 18 | ||||
-rw-r--r-- | src/wallet/ringdb.h | 1 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/wallet/ringdb.cpp b/src/wallet/ringdb.cpp index 44992520f..3f2634c8b 100644 --- a/src/wallet/ringdb.cpp +++ b/src/wallet/ringdb.cpp @@ -190,7 +190,8 @@ namespace tools { ringdb::ringdb(std::string filename, const std::string &genesis): - filename(filename) + filename(filename), + env(NULL) { MDB_txn *txn; bool tx_active = false; @@ -227,9 +228,18 @@ ringdb::ringdb(std::string filename, const std::string &genesis): ringdb::~ringdb() { - mdb_dbi_close(env, dbi_rings); - mdb_dbi_close(env, dbi_blackballs); - mdb_env_close(env); + close(); +} + +void ringdb::close() +{ + if (env) + { + mdb_dbi_close(env, dbi_rings); + mdb_dbi_close(env, dbi_blackballs); + mdb_env_close(env); + env = NULL; + } } bool ringdb::add_rings(const crypto::chacha_key &chacha_key, const cryptonote::transaction_prefix &tx) diff --git a/src/wallet/ringdb.h b/src/wallet/ringdb.h index 2bd1ac149..6b4bce124 100644 --- a/src/wallet/ringdb.h +++ b/src/wallet/ringdb.h @@ -41,6 +41,7 @@ namespace tools { public: ringdb(std::string filename, const std::string &genesis); + void close(); ~ringdb(); bool add_rings(const crypto::chacha_key &chacha_key, const cryptonote::transaction_prefix &tx); |