@@ -470,13 +470,13 @@ class PeerManagerImpl final : public PeerManager
470
470
* - the block has been recieved from a peer
471
471
* - the request for the block has timed out
472
472
*/
473
- void MarkBlockAsReceived (const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
473
+ void RemoveBlockRequest (const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
474
474
475
475
/* Mark a block as in flight
476
476
* Returns false, still setting pit, if the block was already in flight from the same peer
477
477
* pit will only be valid as long as the same cs_main lock is being held
478
478
*/
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);
480
480
481
481
bool TipMayBeStale () EXCLUSIVE_LOCKS_REQUIRED(cs_main);
482
482
@@ -766,7 +766,7 @@ bool PeerManagerImpl::IsBlockRequested(const uint256& hash)
766
766
return mapBlocksInFlight.find (hash) != mapBlocksInFlight.end ();
767
767
}
768
768
769
- void PeerManagerImpl::MarkBlockAsReceived (const uint256& hash)
769
+ void PeerManagerImpl::RemoveBlockRequest (const uint256& hash)
770
770
{
771
771
auto it = mapBlocksInFlight.find (hash);
772
772
if (it == mapBlocksInFlight.end ()) {
@@ -793,7 +793,7 @@ void PeerManagerImpl::MarkBlockAsReceived(const uint256& hash)
793
793
mapBlocksInFlight.erase (it);
794
794
}
795
795
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)
797
797
{
798
798
assert (pindex);
799
799
const uint256& hash{pindex->GetBlockHash ()};
@@ -811,7 +811,7 @@ bool PeerManagerImpl::MarkBlockAsInFlight(NodeId nodeid, const CBlockIndex* pind
811
811
}
812
812
813
813
// Make sure it's not listed somewhere already.
814
- MarkBlockAsReceived (hash);
814
+ RemoveBlockRequest (hash);
815
815
816
816
std::list<QueuedBlock>::iterator it = state->vBlocksInFlight .insert (state->vBlocksInFlight .end (),
817
817
{pindex, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownloadedBlock (&m_mempool) : nullptr )});
@@ -2092,7 +2092,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
2092
2092
}
2093
2093
uint32_t nFetchFlags = GetFetchFlags (pfrom);
2094
2094
vGetData.push_back (CInv (MSG_BLOCK | nFetchFlags, pindex->GetBlockHash ()));
2095
- MarkBlockAsInFlight (pfrom.GetId (), pindex);
2095
+ BlockRequested (pfrom.GetId (), pindex);
2096
2096
LogPrint (BCLog::NET, " Requesting block %s from peer=%d\n " ,
2097
2097
pindex->GetBlockHash ().ToString (), pfrom.GetId ());
2098
2098
}
@@ -3395,7 +3395,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3395
3395
if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) ||
3396
3396
(fAlreadyInFlight && blockInFlightIt->second .first == pfrom.GetId ())) {
3397
3397
std::list<QueuedBlock>::iterator* queuedBlockIt = nullptr ;
3398
- if (!MarkBlockAsInFlight (pfrom.GetId (), pindex, &queuedBlockIt)) {
3398
+ if (!BlockRequested (pfrom.GetId (), pindex, &queuedBlockIt)) {
3399
3399
if (!(*queuedBlockIt)->partialBlock )
3400
3400
(*queuedBlockIt)->partialBlock .reset (new PartiallyDownloadedBlock (&m_mempool));
3401
3401
else {
@@ -3408,7 +3408,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3408
3408
PartiallyDownloadedBlock& partialBlock = *(*queuedBlockIt)->partialBlock ;
3409
3409
ReadStatus status = partialBlock.InitData (cmpctblock, vExtraTxnForCompact);
3410
3410
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
3412
3412
Misbehaving (pfrom.GetId (), 100 , " invalid compact block" );
3413
3413
return ;
3414
3414
} else if (status == READ_STATUS_FAILED) {
@@ -3503,7 +3503,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3503
3503
// process from some other peer. We do this after calling
3504
3504
// ProcessNewBlock so that a malleated cmpctblock announcement
3505
3505
// can't be used to interfere with block relay.
3506
- MarkBlockAsReceived (pblock->GetHash ());
3506
+ RemoveBlockRequest (pblock->GetHash ());
3507
3507
}
3508
3508
}
3509
3509
return ;
@@ -3535,7 +3535,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3535
3535
PartiallyDownloadedBlock& partialBlock = *it->second .second ->partialBlock ;
3536
3536
ReadStatus status = partialBlock.FillBlock (*pblock, resp.txn );
3537
3537
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
3539
3539
Misbehaving (pfrom.GetId (), 100 , " invalid compact block/non-matching block transactions" );
3540
3540
return ;
3541
3541
} else if (status == READ_STATUS_FAILED) {
@@ -3561,7 +3561,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3561
3561
// though the block was successfully read, and rely on the
3562
3562
// handling in ProcessNewBlock to ensure the block index is
3563
3563
// updated, etc.
3564
- MarkBlockAsReceived (resp.blockhash ); // it is now an empty pointer
3564
+ RemoveBlockRequest (resp.blockhash ); // it is now an empty pointer
3565
3565
fBlockRead = true ;
3566
3566
// mapBlockSource is used for potentially punishing peers and
3567
3567
// updating which peers send us compact blocks, so the race
@@ -3629,7 +3629,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
3629
3629
// Always process the block if we requested it, since we may
3630
3630
// need it even when it's not a candidate for a new best tip.
3631
3631
forceProcessing = IsBlockRequested (hash);
3632
- MarkBlockAsReceived (hash);
3632
+ RemoveBlockRequest (hash);
3633
3633
// mapBlockSource is only used for punishing peers and setting
3634
3634
// which peers send us compact blocks, so the race between here and
3635
3635
// cs_main in ProcessNewBlock is fine.
@@ -4779,7 +4779,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
4779
4779
for (const CBlockIndex *pindex : vToDownload) {
4780
4780
uint32_t nFetchFlags = GetFetchFlags (*pto);
4781
4781
vGetData.push_back (CInv (MSG_BLOCK | nFetchFlags, pindex->GetBlockHash ()));
4782
- MarkBlockAsInFlight (pto->GetId (), pindex);
4782
+ BlockRequested (pto->GetId (), pindex);
4783
4783
LogPrint (BCLog::NET, " Requesting block %s (%d) peer=%d\n " , pindex->GetBlockHash ().ToString (),
4784
4784
pindex->nHeight , pto->GetId ());
4785
4785
}
0 commit comments