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
@@ -295,6 +295,7 @@ namespace cryptonote
<< " [Your node is " << std::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"))
<< "] " << ENDL << "SYNCHRONIZATION started");
m_core.get_blockchain_storage().safesyncmode(false);
}
LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id);
context.m_state = cryptonote_connection_context::state_synchronizing;
@@ -1473,6 +1474,7 @@ skip:
<< "**********************************************************************");
m_core.on_synchronized();
}
m_core.get_blockchain_storage().safesyncmode(true);
return true;
}
//------------------------------------------------------------------------------------------------------------------------