diff options
| author | tobtoht <tob@featherwallet.org> | 2025-02-13 17:35:32 +0000 |
|---|---|---|
| committer | tobtoht <tob@featherwallet.org> | 2025-02-13 17:35:32 +0000 |
| commit | 71c8a726e52513ca358c50a9400988d67a92f7e2 (patch) | |
| tree | 29ab3bbc94fe9cd0b61d11a925a9acbbb594334e /src/cryptonote_basic/connection_context.cpp | |
| parent | bea29939125c8e85cc266b46ebd0b07b0eb04747 (diff) | |
| parent | ed70c162244b7b42119e2011bb5cf90061160629 (diff) | |
| download | monzero-core-71c8a726e52513ca358c50a9400988d67a92f7e2.tar.gz monzero-core-71c8a726e52513ca358c50a9400988d67a92f7e2.tar.xz monzero-core-71c8a726e52513ca358c50a9400988d67a92f7e2.zip | |
Merge pull request #9759
ed70c1622 Some cleanup in span/connection_context + few more checks (Lee *!* Clagett)
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 |
