refactor: use c++20 std::views::reverse instead of reverse_iterator.h

Use std::ranges::views::reverse instead of the implementation in
reverse_iterator.h, and remove it as it is no longer used.
This commit is contained in:
stickies-v
2023-10-19 12:46:32 +01:00
parent 949b673472
commit 2925bd537c
9 changed files with 22 additions and 66 deletions

View File

@@ -32,7 +32,6 @@
#include <primitives/block.h>
#include <primitives/transaction.h>
#include <random.h>
#include <reverse_iterator.h>
#include <scheduler.h>
#include <streams.h>
#include <sync.h>
@@ -51,6 +50,7 @@
#include <future>
#include <memory>
#include <optional>
#include <ranges>
#include <typeinfo>
#include <utility>
@@ -2259,7 +2259,7 @@ void PeerManagerImpl::UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlock
for (auto& it : m_peer_map) {
Peer& peer = *it.second;
LOCK(peer.m_block_inv_mutex);
for (const uint256& hash : reverse_iterate(vHashes)) {
for (const uint256& hash : vHashes | std::views::reverse) {
peer.m_blocks_for_headers_relay.push_back(hash);
}
}
@@ -2958,7 +2958,7 @@ void PeerManagerImpl::HeadersDirectFetchBlocks(CNode& pfrom, const Peer& peer, c
} else {
std::vector<CInv> vGetData;
// Download as much as possible, from earliest to latest.
for (const CBlockIndex *pindex : reverse_iterate(vToFetch)) {
for (const CBlockIndex* pindex : vToFetch | std::views::reverse) {
if (nodestate->vBlocksInFlight.size() >= MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
// Can't download any more from this peer
break;