diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-07-04 21:44:43 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2019-07-04 21:57:05 +0000 |
commit | 1542d5d978b548167fb8852ed4bbbf3030a83ed0 (patch) | |
tree | 864a873c216696d05687562e91ebea4a703a1ae1 | |
parent | p2p: add a few missing connection close calls (diff) | |
download | monero-1542d5d978b548167fb8852ed4bbbf3030a83ed0.tar.xz |
cryptonote_protocol: drop peers we can't download from when syncing
Any peer that's behind us while syncing is useless to us (though
not to them). This ensures that we don't get our peer slots filled
with peers that we can't use. Once we've synced, we can connect
to them and they can then sync off us if they want.
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index b38407840..03d04a074 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -341,6 +341,11 @@ namespace cryptonote if(m_core.have_block(hshd.top_id)) { + if (target > hshd.current_height) + { + MINFO(context << "peer is not ahead of us and we're syncing, disconnecting"); + return false; + } context.m_state = cryptonote_connection_context::state_normal; if(is_inital && target == m_core.get_current_blockchain_height()) on_connection_synchronized(); |