mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-05 20:50:18 +02:00
Merge #21235: p2p: Clarify disconnect log message in ProcessGetBlockData, remove send bool
fa8177324392c923c6ce39056cfd870af55ab673 style-only: Remove whitespace (MarcoFalke) fae77b9e6dc9e59b355d56df49c4d9685b6f40a4 net: Simplify ProcessGetBlockData execution by removing send flag. (Patrick Strateman) fae7c0429f96e08bcac944f6fa30264636dfda8c log: Clarify that block request below NODE_NETWORK_LIMITED_MIN_BLOCKS disconnects (MarcoFalke) Pull request description: * Clarify that "ignoring" really means "disconnect" in the log * Revive a refactor I took from #13670 ACKs for top commit: jnewbery: utACK fa8177324392c923c6ce39056cfd870af55ab673 sipa: utACK fa8177324392c923c6ce39056cfd870af55ab673 Tree-SHA512: 0a4fcb979cb82c4e26012881eeaf903c38dfbb85d461476c01e35294760744746a79c48ffad827fe31c1b830f40c6e4240529c71e375146e4d0313c3b7d784ca
This commit is contained in:
commit
3a12fdba51
@ -1530,7 +1530,6 @@ static void RelayAddress(const CNode& originator,
|
||||
|
||||
void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv& inv)
|
||||
{
|
||||
bool send = false;
|
||||
std::shared_ptr<const CBlock> a_recent_block;
|
||||
std::shared_ptr<const CBlockHeaderAndShortTxIDs> a_recent_compact_block;
|
||||
bool fWitnessesPresentInARecentCompactBlock;
|
||||
@ -1566,39 +1565,37 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
||||
|
||||
LOCK(cs_main);
|
||||
const CBlockIndex* pindex = m_chainman.m_blockman.LookupBlockIndex(inv.hash);
|
||||
if (pindex) {
|
||||
send = BlockRequestAllowed(pindex);
|
||||
if (!send) {
|
||||
LogPrint(BCLog::NET, "%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom.GetId());
|
||||
if (!pindex) {
|
||||
return;
|
||||
}
|
||||
if (!BlockRequestAllowed(pindex)) {
|
||||
LogPrint(BCLog::NET, "%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom.GetId());
|
||||
return;
|
||||
}
|
||||
const CNetMsgMaker msgMaker(pfrom.GetCommonVersion());
|
||||
// disconnect node in case we have reached the outbound limit for serving historical blocks
|
||||
if (send &&
|
||||
m_connman.OutboundTargetReached(true) &&
|
||||
if (m_connman.OutboundTargetReached(true) &&
|
||||
(((pindexBestHeader != nullptr) && (pindexBestHeader->GetBlockTime() - pindex->GetBlockTime() > HISTORICAL_BLOCK_AGE)) || inv.IsMsgFilteredBlk()) &&
|
||||
!pfrom.HasPermission(PF_DOWNLOAD) // nodes with the download permission may exceed target
|
||||
) {
|
||||
LogPrint(BCLog::NET, "historical block serving limit reached, disconnect peer=%d\n", pfrom.GetId());
|
||||
|
||||
//disconnect node
|
||||
pfrom.fDisconnect = true;
|
||||
send = false;
|
||||
return;
|
||||
}
|
||||
// Avoid leaking prune-height by never sending blocks below the NODE_NETWORK_LIMITED threshold
|
||||
if (send && !pfrom.HasPermission(PF_NOBAN) && (
|
||||
if (!pfrom.HasPermission(PF_NOBAN) && (
|
||||
(((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 */) )
|
||||
)) {
|
||||
LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold from peer=%d\n", pfrom.GetId());
|
||||
|
||||
LogPrint(BCLog::NET, "Ignore block request below NODE_NETWORK_LIMITED threshold, disconnect peer=%d\n", pfrom.GetId());
|
||||
//disconnect node and prevent it from stalling (would otherwise wait for the missing block)
|
||||
pfrom.fDisconnect = true;
|
||||
send = false;
|
||||
return;
|
||||
}
|
||||
// Pruned nodes may have deleted the block, so check whether
|
||||
// it's available before trying to send.
|
||||
if (send && (pindex->nStatus & BLOCK_HAVE_DATA))
|
||||
{
|
||||
if (!(pindex->nStatus & BLOCK_HAVE_DATA)) {
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<const CBlock> pblock;
|
||||
if (a_recent_block && a_recent_block->GetHash() == pindex->GetBlockHash()) {
|
||||
pblock = a_recent_block;
|
||||
@ -1681,7 +1678,6 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
|
||||
peer.m_continuation_block.SetNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CTransactionRef PeerManagerImpl::FindTxForGetData(const CNode& peer, const GenTxid& gtxid, const std::chrono::seconds mempool_req, const std::chrono::seconds now)
|
||||
|
Loading…
x
Reference in New Issue
Block a user