Skip to content

Commit 2f4ad6b

Browse files
committed
scripted-diff: rename MarkBlockAs functions
-BEGIN VERIFY SCRIPT- ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); } ren MarkBlockAsInFlight BlockRequested ren MarkBlockAsReceived RemoveBlockRequest -END VERIFY SCRIPT-
1 parent 2c45f83 commit 2f4ad6b

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/net_processing.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,13 @@ class PeerManagerImpl final : public PeerManager
470470
* - the block has been recieved from a peer
471471
* - the request for the block has timed out
472472
*/
473-
void MarkBlockAsReceived(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
473+
void RemoveBlockRequest(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
474474

475475
/* Mark a block as in flight
476476
* Returns false, still setting pit, if the block was already in flight from the same peer
477477
* pit will only be valid as long as the same cs_main lock is being held
478478
*/
479-
bool MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
479+
bool BlockRequested(NodeId nodeid, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
480480

481481
bool TipMayBeStale() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
482482

@@ -766,7 +766,7 @@ bool PeerManagerImpl::IsBlockRequested(const uint256& hash)
766766
return mapBlocksInFlight.find(hash) != mapBlocksInFlight.end();
767767
}
768768

769-
void PeerManagerImpl::MarkBlockAsReceived(const uint256& hash)
769+
void PeerManagerImpl::RemoveBlockRequest(const uint256& hash)
770770
{
771771
auto it = mapBlocksInFlight.find(hash);
772772
if (it == mapBlocksInFlight.end()) {
@@ -793,7 +793,7 @@ void PeerManagerImpl::MarkBlockAsReceived(const uint256& hash)
793793
mapBlocksInFlight.erase(it);
794794
}
795795

796-
bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit)
796+
bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex* pindex, std::list<QueuedBlock>::iterator** pit)
797797
{
798798
assert(pindex);
799799
const uint256& hash{pindex->GetBlockHash()};
@@ -811,7 +811,7 @@ bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pind
811811
}
812812

813813
// Make sure it's not listed somewhere already.
814-
MarkBlockAsReceived(hash);
814+
RemoveBlockRequest(hash);
815815

816816
std::list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksInFlight.end(),
817817
{pindex, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock(&m_mempool) : nullptr)});
@@ -2092,7 +2092,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
20922092
}
20932093
uint32_t nFetchFlags = GetFetchFlags(pfrom);
20942094
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
2095-
MarkBlockAsInFlight(pfrom.GetId(), pindex);
2095+
BlockRequested(pfrom.GetId(), pindex);
20962096
LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n",
20972097
pindex->GetBlockHash().ToString(), pfrom.GetId());
20982098
}
@@ -3395,7 +3395,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
33953395
if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) ||
33963396
(fAlreadyInFlight && blockInFlightIt->second.first == pfrom.GetId())) {
33973397
std::list<QueuedBlock>::iterator* queuedBlockIt = nullptr;
3398-
if (!MarkBlockAsInFlight(pfrom.GetId(), pindex, &queuedBlockIt)) {
3398+
if (!BlockRequested(pfrom.GetId(), pindex, &queuedBlockIt)) {
33993399
if (!(*queuedBlockIt)->partialBlock)
34003400
(*queuedBlockIt)->partialBlock.reset(new PartiallyDownloadedBlock(&m_mempool));
34013401
else {
@@ -3408,7 +3408,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
34083408
PartiallyDownloadedBlock& partialBlock = *(*queuedBlockIt)->partialBlock;
34093409
ReadStatus status = partialBlock.InitData(cmpctblock, vExtraTxnForCompact);
34103410
if (status == READ_STATUS_INVALID) {
3411-
MarkBlockAsReceived(pindex->GetBlockHash()); // Reset in-flight state in case Misbehaving does not result in a disconnect
3411+
RemoveBlockRequest(pindex->GetBlockHash()); // Reset in-flight state in case Misbehaving does not result in a disconnect
34123412
Misbehaving(pfrom.GetId(), 100, "invalid compact block");
34133413
return;
34143414
} else if (status == READ_STATUS_FAILED) {
@@ -3503,7 +3503,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
35033503
// process from some other peer. We do this after calling
35043504
// ProcessNewBlock so that a malleated cmpctblock announcement
35053505
// can't be used to interfere with block relay.
3506-
MarkBlockAsReceived(pblock->GetHash());
3506+
RemoveBlockRequest(pblock->GetHash());
35073507
}
35083508
}
35093509
return;
@@ -3535,7 +3535,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
35353535
PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock;
35363536
ReadStatus status = partialBlock.FillBlock(*pblock, resp.txn);
35373537
if (status == READ_STATUS_INVALID) {
3538-
MarkBlockAsReceived(resp.blockhash); // Reset in-flight state in case Misbehaving does not result in a disconnect
3538+
RemoveBlockRequest(resp.blockhash); // Reset in-flight state in case Misbehaving does not result in a disconnect
35393539
Misbehaving(pfrom.GetId(), 100, "invalid compact block/non-matching block transactions");
35403540
return;
35413541
} else if (status == READ_STATUS_FAILED) {
@@ -3561,7 +3561,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
35613561
// though the block was successfully read, and rely on the
35623562
// handling in ProcessNewBlock to ensure the block index is
35633563
// updated, etc.
3564-
MarkBlockAsReceived(resp.blockhash); // it is now an empty pointer
3564+
RemoveBlockRequest(resp.blockhash); // it is now an empty pointer
35653565
fBlockRead = true;
35663566
// mapBlockSource is used for potentially punishing peers and
35673567
// updating which peers send us compact blocks, so the race
@@ -3629,7 +3629,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
36293629
// Always process the block if we requested it, since we may
36303630
// need it even when it's not a candidate for a new best tip.
36313631
forceProcessing = IsBlockRequested(hash);
3632-
MarkBlockAsReceived(hash);
3632+
RemoveBlockRequest(hash);
36333633
// mapBlockSource is only used for punishing peers and setting
36343634
// which peers send us compact blocks, so the race between here and
36353635
// cs_main in ProcessNewBlock is fine.
@@ -4779,7 +4779,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
47794779
for (const CBlockIndex *pindex : vToDownload) {
47804780
uint32_t nFetchFlags = GetFetchFlags(*pto);
47814781
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
4782-
MarkBlockAsInFlight(pto->GetId(), pindex);
4782+
BlockRequested(pto->GetId(), pindex);
47834783
LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
47844784
pindex->nHeight, pto->GetId());
47854785
}

0 commit comments

Comments
 (0)