aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-05-31 14:41:17 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-05-31 14:41:17 -0500
commitb6eb7484d1f8b7055a20f116b07a0787019e2be7 (patch)
tree884cec37eb1760515b89602afe0188c05e697b46 /src/wallet
parentMerge pull request #3583 (diff)
parentunit_tests: add ringdb unit tests (diff)
downloadmonero-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.cpp18
-rw-r--r--src/wallet/ringdb.h1
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);