aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2021-06-03 12:33:16 +0100
committerJohn Newbery <john@johnnewbery.com>2021-06-03 12:39:55 +0100
commit85e058b19145b5068f2f71a90c1182bf2a93c473 (patch)
tree724e788d18dfb3e8863046b5b2941818520272aa /src/net_processing.cpp
parenta9435e34457e0bfebd22e574fe63428537948aeb (diff)
downloadbitcoin-85e058b19145b5068f2f71a90c1182bf2a93c473.tar.xz
[net processing] Remove unnecessary hash arg from MarkBlockAsInFlight()
MarkBlockAsInFlight is always called with a non-null pindex. Just get the block hash from that pindex inside the function.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 65224b4259..9a6c62a81f 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -472,7 +472,7 @@ private:
* Returns false, still setting pit, if the block was already in flight from the same peer
* pit will only be valid as long as the same cs_main lock is being held
*/
- bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr, std::list<QueuedBlock>::iterator** pit = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+ bool MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool TipMayBeStale() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
@@ -782,8 +782,11 @@ bool PeerManagerImpl::MarkBlockAsReceived(const uint256& hash)
return false;
}
-bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit)
+bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit)
{
+ assert(pindex);
+ const uint256& hash{pindex->GetBlockHash()};
+
CNodeState *state = State(nodeid);
assert(state != nullptr);
@@ -807,7 +810,7 @@ bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, co
// We're starting a block download (batch) from this peer.
state->m_downloading_since = GetTime<std::chrono::microseconds>();
}
- if (state->nBlocksInFlightValidHeaders == 1 && pindex != nullptr) {
+ if (state->nBlocksInFlightValidHeaders == 1) {
nPeersWithValidatedDownloads++;
}
itInFlight = mapBlocksInFlight.insert(std::make_pair(hash, std::make_pair(nodeid, it))).first;
@@ -2081,7 +2084,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
}
uint32_t nFetchFlags = GetFetchFlags(pfrom);
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
- MarkBlockAsInFlight(pfrom.GetId(), pindex->GetBlockHash(), pindex);
+ MarkBlockAsInFlight(pfrom.GetId(), pindex);
LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n",
pindex->GetBlockHash().ToString(), pfrom.GetId());
}
@@ -3384,7 +3387,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) ||
(fAlreadyInFlight && blockInFlightIt->second.first == pfrom.GetId())) {
std::list<QueuedBlock>::iterator* queuedBlockIt = nullptr;
- if (!MarkBlockAsInFlight(pfrom.GetId(), pindex->GetBlockHash(), pindex, &queuedBlockIt)) {
+ if (!MarkBlockAsInFlight(pfrom.GetId(), pindex, &queuedBlockIt)) {
if (!(*queuedBlockIt)->partialBlock)
(*queuedBlockIt)->partialBlock.reset(new PartiallyDownloadedBlock(&m_mempool));
else {
@@ -4767,7 +4770,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
for (const CBlockIndex *pindex : vToDownload) {
uint32_t nFetchFlags = GetFetchFlags(*pto);
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
- MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex);
+ MarkBlockAsInFlight(pto->GetId(), pindex);
LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
pindex->nHeight, pto->GetId());
}