@@ -1530,7 +1530,6 @@ static void RelayAddress(const CNode& originator,
1530
1530
1531
1531
void PeerManagerImpl::ProcessGetBlockData (CNode& pfrom, Peer& peer, const CInv& inv)
1532
1532
{
1533
- bool send = false ;
1534
1533
std::shared_ptr<const CBlock> a_recent_block;
1535
1534
std::shared_ptr<const CBlockHeaderAndShortTxIDs> a_recent_compact_block;
1536
1535
bool fWitnessesPresentInARecentCompactBlock ;
@@ -1566,35 +1565,37 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
1566
1565
1567
1566
LOCK (cs_main);
1568
1567
const CBlockIndex* pindex = m_chainman.m_blockman .LookupBlockIndex (inv.hash );
1569
- if (pindex) {
1570
- send = BlockRequestAllowed (pindex);
1571
- if (!send) {
1572
- LogPrint (BCLog::NET, " %s: ignoring request from peer=%i for old block that isn't in the main chain\n " , __func__, pfrom.GetId ());
1573
- }
1568
+ if (!pindex) {
1569
+ return ;
1570
+ }
1571
+ if (!BlockRequestAllowed (pindex)) {
1572
+ LogPrint (BCLog::NET, " %s: ignoring request from peer=%i for old block that isn't in the main chain\n " , __func__, pfrom.GetId ());
1573
+ return ;
1574
1574
}
1575
1575
const CNetMsgMaker msgMaker (pfrom.GetCommonVersion ());
1576
1576
// disconnect node in case we have reached the outbound limit for serving historical blocks
1577
- if (send &&
1578
- m_connman.OutboundTargetReached (true ) &&
1577
+ if (m_connman.OutboundTargetReached (true ) &&
1579
1578
(((pindexBestHeader != nullptr ) && (pindexBestHeader->GetBlockTime () - pindex->GetBlockTime () > HISTORICAL_BLOCK_AGE)) || inv.IsMsgFilteredBlk ()) &&
1580
1579
!pfrom.HasPermission (PF_DOWNLOAD) // nodes with the download permission may exceed target
1581
1580
) {
1582
1581
LogPrint (BCLog::NET, " historical block serving limit reached, disconnect peer=%d\n " , pfrom.GetId ());
1583
1582
pfrom.fDisconnect = true ;
1584
- send = false ;
1583
+ return ;
1585
1584
}
1586
1585
// Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
1587
- if (send && !pfrom.HasPermission (PF_NOBAN) && (
1586
+ if (!pfrom.HasPermission (PF_NOBAN) && (
1588
1587
(((pfrom.GetLocalServices () & NODE_NETWORK_LIMITED) == NODE_NETWORK_LIMITED) && ((pfrom.GetLocalServices () & NODE_NETWORK) != NODE_NETWORK) && (m_chainman.ActiveChain ().Tip ()->nHeight - pindex->nHeight > (int )NODE_NETWORK_LIMITED_MIN_BLOCKS + 2 /* add two blocks buffer extension for possible races */ ) )
1589
1588
)) {
1590
1589
LogPrint (BCLog::NET, " Ignore block request below NODE_NETWORK_LIMITED threshold, disconnect peer=%d\n " , pfrom.GetId ());
1591
1590
// disconnect node and prevent it from stalling (would otherwise wait for the missing block)
1592
1591
pfrom.fDisconnect = true ;
1593
- send = false ;
1592
+ return ;
1594
1593
}
1595
1594
// Pruned nodes may have deleted the block, so check whether
1596
1595
// it's available before trying to send.
1597
- if (send && (pindex->nStatus & BLOCK_HAVE_DATA))
1596
+ if (!(pindex->nStatus & BLOCK_HAVE_DATA)) {
1597
+ return ;
1598
+ }
1598
1599
{
1599
1600
std::shared_ptr<const CBlock> pblock;
1600
1601
if (a_recent_block && a_recent_block->GetHash () == pindex->GetBlockHash ()) {
0 commit comments