diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-05-28 12:12:19 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-05-30 18:28:53 +0100 |
commit | 22a4cb06095848851dbb95495ac9d02c70336f6f (patch) | |
tree | a58f75e0bfa6159a5ed2b1d5625da85923897083 | |
parent | Merge pull request #3846 (diff) | |
download | monero-22a4cb06095848851dbb95495ac9d02c70336f6f.tar.xz |
core: fix automatic safe db sync mode switching
-rw-r--r-- | src/blockchain_db/lmdb/db_lmdb.cpp | 1 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 11 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/blockchain_db/lmdb/db_lmdb.cpp b/src/blockchain_db/lmdb/db_lmdb.cpp index 5c20c8de4..fbf7629c6 100644 --- a/src/blockchain_db/lmdb/db_lmdb.cpp +++ b/src/blockchain_db/lmdb/db_lmdb.cpp @@ -1346,6 +1346,7 @@ void BlockchainLMDB::sync() void BlockchainLMDB::safesyncmode(const bool onoff) { + MINFO("switching safe mode " << (onoff ? "on" : "off")); mdb_env_set_flags(m_env, MDB_NOSYNC|MDB_MAPASYNC, !onoff); } diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index 01cd56a11..668e7a2b7 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -438,6 +438,7 @@ namespace cryptonote std::vector<std::string> options; boost::trim(db_sync_mode); boost::split(options, db_sync_mode, boost::is_any_of(" :")); + const bool db_sync_mode_is_default = command_line::is_arg_defaulted(vm, cryptonote::arg_db_sync_mode); for(const auto &option : options) MDEBUG("option: " << option); @@ -458,18 +459,18 @@ namespace cryptonote { safemode = true; db_flags = DBF_SAFE; - sync_mode = db_nosync; + sync_mode = db_sync_mode_is_default ? db_defaultsync : db_nosync; } else if(options[0] == "fast") { db_flags = DBF_FAST; - sync_mode = db_async; + sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async; } else if(options[0] == "fastest") { db_flags = DBF_FASTEST; blocks_per_sync = 1000; // default to fastest:async:1000 - sync_mode = db_async; + sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async; } else db_flags = DEFAULT_FLAGS; @@ -478,9 +479,9 @@ namespace cryptonote if(options.size() >= 2 && !safemode) { if(options[1] == "sync") - sync_mode = db_sync; + sync_mode = db_sync_mode_is_default ? db_defaultsync : db_sync; else if(options[1] == "async") - sync_mode = db_async; + sync_mode = db_sync_mode_is_default ? db_defaultsync : db_async; } if(options.size() >= 3 && !safemode) |