diff options
| author | Lee *!* Clagett <code@leeclagett.com> | 2024-10-08 20:27:09 -0400 |
|---|---|---|
| committer | Lee *!* Clagett <code@leeclagett.com> | 2025-02-03 12:04:45 -0500 |
| commit | ed70c162244b7b42119e2011bb5cf90061160629 (patch) | |
| tree | 5efbfb17847c8577f42e96ea06aa449d1e6a008f /src/cryptonote_basic/connection_context.cpp | |
| parent | 5e31c0adf2dd381be0da6e8c471cfeccb8ba594b (diff) | |
| download | monzero-core-ed70c162244b7b42119e2011bb5cf90061160629.tar.gz monzero-core-ed70c162244b7b42119e2011bb5cf90061160629.tar.xz monzero-core-ed70c162244b7b42119e2011bb5cf90061160629.zip | |
Some cleanup in span/connection_context + few more checks
Diffstat (limited to 'src/cryptonote_basic/connection_context.cpp')
| -rw-r--r-- | src/cryptonote_basic/connection_context.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/cryptonote_basic/connection_context.cpp b/src/cryptonote_basic/connection_context.cpp index 4395bad9f..642749f3c 100644 --- a/src/cryptonote_basic/connection_context.cpp +++ b/src/cryptonote_basic/connection_context.cpp @@ -29,6 +29,7 @@ #include "connection_context.h" +#include <boost/optional/optional.hpp> #include "cryptonote_protocol/cryptonote_protocol_defs.h" #include "p2p/p2p_protocol_defs.h" @@ -69,4 +70,23 @@ namespace cryptonote }; return std::numeric_limits<size_t>::max(); } + + void cryptonote_connection_context::set_state_normal() + { + m_state = state_normal; + m_expected_heights_start = 0; + m_needed_objects.clear(); + m_needed_objects.shrink_to_fit(); + m_expected_heights.clear(); + m_expected_heights.shrink_to_fit(); + m_requested_objects.clear(); + } + + boost::optional<crypto::hash> cryptonote_connection_context::get_expected_hash(const uint64_t height) const + { + const auto difference = height - m_expected_heights_start; + if (height < m_expected_heights_start || m_expected_heights.size() < difference) + return boost::none; + return m_expected_heights[difference]; + } } // cryptonote |
