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_protocol/block_queue.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_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); |
