diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index ba8fe5d..2ebb05d 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -1122,7 +1122,7 @@ void P2PServer::download_missing_blocks() return; } - std::vector missing_blocks; + unordered_set missing_blocks; m_pool->side_chain().get_missing_blocks(missing_blocks); if (missing_blocks.empty()) { @@ -1178,7 +1178,7 @@ void P2PServer::download_missing_blocks() const bool result = send(client, [&id, client](uint8_t* buf, size_t buf_size) -> size_t { - LOGINFO(5, "sending BLOCK_REQUEST for id = " << id << " to " << static_cast(client->m_addrString)); + LOGINFO(5, "[download_missing_blocks] sending BLOCK_REQUEST for id = " << id << " to " << static_cast(client->m_addrString)); if (buf_size < 1 + HASH_SIZE) { return 0; @@ -2368,7 +2368,7 @@ void P2PServer::P2PClient::on_block_notify(const uint8_t* buf) const bool result = server->send(this, [&id, this](uint8_t* buf, size_t buf_size) -> size_t { - LOGINFO(5, "sending BLOCK_REQUEST for id = " << id << " to " << static_cast(m_addrString)); + LOGINFO(5, "[on_block_notify] sending BLOCK_REQUEST for id = " << id << " to " << static_cast(m_addrString)); if (buf_size < 1 + HASH_SIZE) { return 0; @@ -2546,7 +2546,7 @@ void P2PServer::P2PClient::post_handle_incoming_block(const PoolBlock& block, co const bool result = server->send(this, [this, &id](uint8_t* buf, size_t buf_size) -> size_t { - LOGINFO(5, "sending BLOCK_REQUEST for id = " << id << " to " << static_cast(m_addrString)); + LOGINFO(5, "[post_handle_incoming_block] sending BLOCK_REQUEST for id = " << id << " to " << static_cast(m_addrString)); if (buf_size < 1 + HASH_SIZE) { return 0; diff --git a/src/side_chain.cpp b/src/side_chain.cpp index b33fab8..cb6a05c 100644 --- a/src/side_chain.cpp +++ b/src/side_chain.cpp @@ -2088,7 +2088,7 @@ void SideChain::prune_old_blocks() } } -void SideChain::get_missing_blocks(std::vector& missing_blocks) const +void SideChain::get_missing_blocks(unordered_set& missing_blocks) const { missing_blocks.clear(); @@ -2100,14 +2100,14 @@ void SideChain::get_missing_blocks(std::vector& missing_blocks) const } if (!b.second->m_parent.empty() && (m_blocksById.find(b.second->m_parent) == m_blocksById.end())) { - missing_blocks.push_back(b.second->m_parent); + missing_blocks.insert(b.second->m_parent); } int num_missing_uncles = 0; for (const hash& h : b.second->m_uncles) { if (!h.empty() && (m_blocksById.find(h) == m_blocksById.end())) { - missing_blocks.push_back(h); + missing_blocks.insert(h); // Get no more than 2 first missing uncles at a time from each block // Blocks with more than 2 uncles are very rare and they will be processed in several steps diff --git a/src/side_chain.h b/src/side_chain.h index d1f2d33..8746cdc 100644 --- a/src/side_chain.h +++ b/src/side_chain.h @@ -52,7 +52,7 @@ public: bool add_external_block(PoolBlock& block, std::vector& missing_blocks); bool add_block(const PoolBlock& block); - void get_missing_blocks(std::vector& missing_blocks) const; + void get_missing_blocks(unordered_set& missing_blocks) const; PoolBlock* find_block(const hash& id) const; void watch_mainchain_block(const ChainMain& data, const hash& possible_id);