aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2017-08-26 23:43:22 +0200
committerRiccardo Spagni <ric@spagni.net>2017-08-26 23:43:22 +0200
commit36b978f50e668f06f16607d902be5132412d4d97 (patch)
tree9d5fd313162a7a43e521dc2e7aff01c27e1ab768 /src/blockchain_db
parentMerge pull request #2313 (diff)
parentCleanup test impact of adding safesyncmode() method (diff)
downloadmonero-36b978f50e668f06f16607d902be5132412d4d97.tar.xz
Merge pull request #2314
c22d22e2 Cleanup test impact of adding safesyncmode() method (Howard Chu) 9a859844 Toggle SAFE syncmode on and off automatically (Howard Chu)
Diffstat (limited to 'src/blockchain_db')
-rw-r--r--src/blockchain_db/blockchain_db.h7
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp5
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
3 files changed, 14 insertions, 0 deletions
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index 3efb8c3c3..ad246d85e 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -606,6 +606,13 @@ public:
virtual void sync() = 0;
/**
+ * @brief toggle safe syncs for the DB
+ *
+ * Used to switch DBF_SAFE on or off after starting up with DBF_FAST.
+ */
+ virtual void safesyncmode(const bool onoff) = 0;
+
+ /**
* @brief Remove everything from the BlockchainDB
*
* This function should completely remove all data from a BlockchainDB.
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp
index a756c04c6..4100d9cca 100644
--- a/src/blockchain_db/lmdb/db_lmdb.cpp
+++ b/src/blockchain_db/lmdb/db_lmdb.cpp
@@ -1318,6 +1318,11 @@ void BlockchainLMDB::sync()
}
}
+void BlockchainLMDB::safesyncmode(const bool onoff)
+{
+ mdb_env_set_flags(m_env, MDB_NOSYNC|MDB_MAPASYNC, !onoff);
+}
+
void BlockchainLMDB::reset()
{
LOG_PRINT_L3("BlockchainLMDB::" << __func__);
diff --git a/src/blockchain_db/lmdb/db_lmdb.h b/src/blockchain_db/lmdb/db_lmdb.h
index 14e5d34e2..3a11ddf0d 100644
--- a/src/blockchain_db/lmdb/db_lmdb.h
+++ b/src/blockchain_db/lmdb/db_lmdb.h
@@ -165,6 +165,8 @@ public:
virtual void sync();
+ virtual void safesyncmode(const bool onoff);
+
virtual void reset();
virtual std::vector<std::string> get_filenames() const;