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_protocol/block_queue.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_protocol/block_queue.cpp')
| -rw-r--r-- | src/cryptonote_protocol/block_queue.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/cryptonote_protocol/block_queue.cpp b/src/cryptonote_protocol/block_queue.cpp index e5a4c0c99..f8962df06 100644 --- a/src/cryptonote_protocol/block_queue.cpp +++ b/src/cryptonote_protocol/block_queue.cpp @@ -51,10 +51,10 @@ void block_queue::add_blocks(uint64_t height, std::vector<cryptonote::block_comp blocks.insert(span(height, std::move(bcel), connection_id, addr, rate, size)); if (has_hashes) { - for (const crypto::hash &h: hashes) + for (std::size_t i = 0; i < hashes.size(); ++i) { - requested_hashes.insert(h); - have_blocks.insert(h); + requested_hashes.insert(hashes[i]); + have_blocks.emplace(hashes[i], height + i); } set_span_hashes(height, connection_id, hashes); } @@ -219,6 +219,16 @@ bool block_queue::have(const crypto::hash &hash) const return have_blocks.find(hash) != have_blocks.end(); } +std::uint64_t block_queue::have_height(const crypto::hash &hash) const +{ + boost::unique_lock<boost::recursive_mutex> lock(mutex); + const auto elem = have_blocks.find(hash); + if (elem == have_blocks.end()) + return std::numeric_limits<std::uint64_t>::max(); + return elem->second; +} + + std::pair<uint64_t, uint64_t> block_queue::reserve_span(uint64_t first_block_height, uint64_t last_block_height, uint64_t max_blocks, const boost::uuids::uuid &connection_id, const epee::net_utils::network_address &addr, bool sync_pruned_blocks, uint32_t local_pruning_seed, uint32_t pruning_seed, uint64_t blockchain_height, const std::vector<std::pair<crypto::hash, uint64_t>> &block_hashes, boost::posix_time::ptime time) { boost::unique_lock<boost::recursive_mutex> lock(mutex); |
