mirror of
https://github.com/monero-project/monero.git
synced 2024-12-28 08:29:28 -05:00
Merge pull request #3884
49cf41a6
protocol: do not switch to unsafe sync mode for just a few blocks (moneromooo-monero)22a4cb06
core: fix automatic safe db sync mode switching (moneromooo-monero)
This commit is contained in:
commit
65c69fb67e
@ -1346,6 +1346,7 @@ void BlockchainLMDB::sync()
|
|||||||
|
|
||||||
void BlockchainLMDB::safesyncmode(const bool onoff)
|
void BlockchainLMDB::safesyncmode(const bool onoff)
|
||||||
{
|
{
|
||||||
|
MINFO("switching safe mode " << (onoff ? "on" : "off"));
|
||||||
mdb_env_set_flags(m_env, MDB_NOSYNC|MDB_MAPASYNC, !onoff);
|
mdb_env_set_flags(m_env, MDB_NOSYNC|MDB_MAPASYNC, !onoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,6 +438,7 @@ namespace cryptonote
|
|||||||
std::vector<std::string> options;
|
std::vector<std::string> options;
|
||||||
boost::trim(db_sync_mode);
|
boost::trim(db_sync_mode);
|
||||||
boost::split(options, db_sync_mode, boost::is_any_of(" :"));
|
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)
|
for(const auto &option : options)
|
||||||
MDEBUG("option: " << option);
|
MDEBUG("option: " << option);
|
||||||
@ -458,18 +459,18 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
safemode = true;
|
safemode = true;
|
||||||
db_flags = DBF_SAFE;
|
db_flags = DBF_SAFE;
|
||||||
sync_mode = db_nosync;
|
sync_mode = db_sync_mode_is_default ? db_defaultsync : db_nosync;
|
||||||
}
|
}
|
||||||
else if(options[0] == "fast")
|
else if(options[0] == "fast")
|
||||||
{
|
{
|
||||||
db_flags = DBF_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")
|
else if(options[0] == "fastest")
|
||||||
{
|
{
|
||||||
db_flags = DBF_FASTEST;
|
db_flags = DBF_FASTEST;
|
||||||
blocks_per_sync = 1000; // default to fastest:async:1000
|
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
|
else
|
||||||
db_flags = DEFAULT_FLAGS;
|
db_flags = DEFAULT_FLAGS;
|
||||||
@ -478,9 +479,9 @@ namespace cryptonote
|
|||||||
if(options.size() >= 2 && !safemode)
|
if(options.size() >= 2 && !safemode)
|
||||||
{
|
{
|
||||||
if(options[1] == "sync")
|
if(options[1] == "sync")
|
||||||
sync_mode = db_sync;
|
sync_mode = db_sync_mode_is_default ? db_defaultsync : db_sync;
|
||||||
else if(options[1] == "async")
|
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)
|
if(options.size() >= 3 && !safemode)
|
||||||
|
@ -308,7 +308,8 @@ namespace cryptonote
|
|||||||
<< " [Your node is " << abs_diff << " blocks (" << ((abs_diff - diff_v2) / (24 * 60 * 60 / DIFFICULTY_TARGET_V1)) + (diff_v2 / (24 * 60 * 60 / DIFFICULTY_TARGET_V2)) << " days) "
|
<< " [Your node is " << abs_diff << " blocks (" << ((abs_diff - diff_v2) / (24 * 60 * 60 / DIFFICULTY_TARGET_V1)) + (diff_v2 / (24 * 60 * 60 / DIFFICULTY_TARGET_V2)) << " days) "
|
||||||
<< (0 <= diff ? std::string("behind") : std::string("ahead"))
|
<< (0 <= diff ? std::string("behind") : std::string("ahead"))
|
||||||
<< "] " << ENDL << "SYNCHRONIZATION started");
|
<< "] " << ENDL << "SYNCHRONIZATION started");
|
||||||
m_core.safesyncmode(false);
|
if (hshd.current_height >= m_core.get_current_blockchain_height() + 5) // don't switch to unsafe mode just for a few blocks
|
||||||
|
m_core.safesyncmode(false);
|
||||||
}
|
}
|
||||||
LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id);
|
LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id);
|
||||||
context.m_state = cryptonote_connection_context::state_synchronizing;
|
context.m_state = cryptonote_connection_context::state_synchronizing;
|
||||||
|
Loading…
Reference in New Issue
Block a user