aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/ringdb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/ringdb.cpp')
-rw-r--r--src/wallet/ringdb.cpp18
1 files changed, 14 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)