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.
This commit is contained in:
Howard Chu
2017-08-19 19:36:51 +01:00
parent 4c7f8ac04f
commit 9a859844f4
8 changed files with 47 additions and 2 deletions
+5
View File
@@ -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__);
+2
View File
@@ -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;