diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-12-07 21:39:48 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2017-12-18 15:15:05 +0000 |
commit | 25584f86390513aa15c0b596699f2f3b20875b14 (patch) | |
tree | 4d36b6764291c9b20e83c690fb73273376cada59 /src | |
parent | rpc: do not try to use an invalid txid in relay_tx (diff) | |
download | monero-25584f86390513aa15c0b596699f2f3b20875b14.tar.xz |
cryptonote_protocol: print peer versions when unexpected
also avoid integer underflow on zero height
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.inl | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl index 389e8ba84..dbcc4eba1 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl @@ -266,13 +266,17 @@ namespace cryptonote return true; // from v6, if the peer advertises a top block version, reject if it's not what it should be (will only work if no voting) - const uint8_t version = m_core.get_ideal_hard_fork_version(hshd.current_height - 1); - if (version >= 6 && version != hshd.top_version) + if (hshd.current_height > 0) { - if (version < hshd.top_version) - MCLOG_RED(el::Level::Warning, "global", context << " peer claims higher version that we think - we may be forked from the network and a software upgrade may be needed"); - LOG_DEBUG_CC(context, "Ignoring due to wrong top version for block " << (hshd.current_height - 1) << ": " << (unsigned)hshd.top_version << ", expected " << (unsigned)version); - return false; + const uint8_t version = m_core.get_ideal_hard_fork_version(hshd.current_height - 1); + if (version >= 6 && version != hshd.top_version) + { + if (version < hshd.top_version) + MCLOG_RED(el::Level::Warning, "global", context << " peer claims higher version that we think (" << + (unsigned)hshd.top_version << " for " << (hshd.current_height - 1) << "instead of " << (unsigned)version << + ") - we may be forked from the network and a software upgrade may be needed"); + return false; + } } context.m_remote_blockchain_height = hshd.current_height; |