Fix spurious synchronization status msgs

Only update target height if it's actually greater than the current target.
Only display "synchronized" when current height equals target.
This commit is contained in:
Howard Chu 2017-02-15 06:38:38 -08:00
parent 3f171b931f
commit 424b76a4e5
No known key found for this signature in database
GPG Key ID: FD2A70B44AB11BA7

View File

@ -265,14 +265,17 @@ namespace cryptonote
if(context.m_state == cryptonote_connection_context::state_synchronizing) if(context.m_state == cryptonote_connection_context::state_synchronizing)
return true; return true;
uint64_t target = m_core.get_target_blockchain_height();
if(m_core.have_block(hshd.top_id)) if(m_core.have_block(hshd.top_id))
{ {
context.m_state = cryptonote_connection_context::state_normal; context.m_state = cryptonote_connection_context::state_normal;
if(is_inital) if(is_inital && target == m_core.get_current_blockchain_height())
on_connection_synchronized(); on_connection_synchronized();
return true; return true;
} }
if (hshd.current_height > target)
{
/* As I don't know if accessing hshd from core could be a good practice, /* As I don't know if accessing hshd from core could be a good practice,
I prefer pushing target height to the core at the same time it is pushed to the user. I prefer pushing target height to the core at the same time it is pushed to the user.
Nz. */ Nz. */
@ -286,6 +289,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) " << " [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")) << (0 <= diff ? std::string("behind") : std::string("ahead"))
<< "] " << ENDL << "SYNCHRONIZATION started"); << "] " << ENDL << "SYNCHRONIZATION started");
}
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;
context.m_remote_blockchain_height = hshd.current_height; context.m_remote_blockchain_height = hshd.current_height;