From 9a859844f496158b8237bbd08ff0f608dc5a6385 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sat, 19 Aug 2017 19:36:51 +0100 Subject: 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. --- src/cryptonote_protocol/cryptonote_protocol_handler.inl | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/cryptonote_protocol') diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index daefe88b7..87c02709a 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -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; } //------------------------------------------------------------------------------------------------------------------------ -- cgit v1.2.3 From c22d22e2db9af50c926f623718b814d041b89c8e Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 22 Aug 2017 14:54:18 +0100 Subject: Cleanup test impact of adding safesyncmode() method --- src/cryptonote_protocol/cryptonote_protocol_handler.inl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cryptonote_protocol') diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 87c02709a..d7c67e767 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -295,7 +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); + m_core.safesyncmode(false); } LOG_PRINT_L1("Remote blockchain height: " << hshd.current_height << ", id: " << hshd.top_id); context.m_state = cryptonote_connection_context::state_synchronizing; @@ -1474,7 +1474,7 @@ skip: << "**********************************************************************"); m_core.on_synchronized(); } - m_core.get_blockchain_storage().safesyncmode(true); + m_core.safesyncmode(true); return true; } //------------------------------------------------------------------------------------------------------------------------ -- cgit v1.2.3