[net processing] ignore tx GETDATA from blocks-only peers

Co-Authored-By: John Newbery <john@johnnewbery.com>
pull/18808/head
Amiti Uttarwar 5 years ago committed by John Newbery
parent eef90c14ed
commit 047ceac142

@ -1595,15 +1595,13 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
std::vector<CInv> vNotFound; std::vector<CInv> vNotFound;
const CNetMsgMaker msgMaker(pfrom->GetSendVersion()); const CNetMsgMaker msgMaker(pfrom->GetSendVersion());
// Note that if we receive a getdata for a MSG_TX or MSG_WITNESS_TX from a
// block-relay-only outbound peer, we will stop processing further getdata
// messages from this peer (likely resulting in our peer eventually
// disconnecting us).
if (pfrom->m_tx_relay != nullptr) {
// mempool entries added before this time have likely expired from mapRelay // mempool entries added before this time have likely expired from mapRelay
const std::chrono::seconds longlived_mempool_time = GetTime<std::chrono::seconds>() - RELAY_TX_CACHE_TIME; const std::chrono::seconds longlived_mempool_time = GetTime<std::chrono::seconds>() - RELAY_TX_CACHE_TIME;
const std::chrono::seconds mempool_req = pfrom->m_tx_relay->m_last_mempool_req.load(); // Get last mempool request time
const std::chrono::seconds mempool_req = pfrom->m_tx_relay != nullptr ? pfrom->m_tx_relay->m_last_mempool_req.load()
: std::chrono::seconds::min();
{
LOCK(cs_main); LOCK(cs_main);
while (it != pfrom->vRecvGetData.end() && (it->type == MSG_TX || it->type == MSG_WITNESS_TX)) { while (it != pfrom->vRecvGetData.end() && (it->type == MSG_TX || it->type == MSG_WITNESS_TX)) {
@ -1613,8 +1611,12 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm
if (pfrom->fPauseSend) if (pfrom->fPauseSend)
break; break;
const CInv &inv = *it; const CInv &inv = *it++;
it++;
if (pfrom->m_tx_relay == nullptr) {
// Ignore GETDATA requests for transactions from blocks-only peers.
continue;
}
// Send stream from relay memory // Send stream from relay memory
bool push = false; bool push = false;

Loading…
Cancel
Save