mirror of
https://github.com/monero-project/monero.git
synced 2026-02-05 11:26:29 -08:00
Some cleanup in span/connection_context + few more checks
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user