aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/lmdb
diff options
context:
space:
mode:
authorHoward Chu <hyc@symas.com>2017-08-19 19:36:51 +0100
committerHoward Chu <hyc@symas.com>2017-08-20 16:30:28 +0100
commit9a859844f496158b8237bbd08ff0f608dc5a6385 (patch)
tree01b471ca8a5f334112bd777a10962853aedbffe3 /src/blockchain_db/lmdb
parentDB cleanup (diff)
downloadmonero-9a859844f496158b8237bbd08ff0f608dc5a6385.tar.xz
Toggle SAFE syncmode on and off automatically
If monerod is started with default sync mode, set it to SAFE after synchronization completes. Set it back to FAST if synchronization restarts (e.g. because another peer has a longer blockchain). If monerod is started with an explicit sync mode, none of this automation takes effect.
Diffstat (limited to 'src/blockchain_db/lmdb')
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.cpp5
-rw-r--r--src/blockchain_db/lmdb/db_lmdb.h2
2 files changed, 7 insertions, 0 deletions
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;