diff options
author | Amiti Uttarwar <amiti@uttarwar.org> | 2020-04-27 13:59:37 -0700 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2020-05-15 07:42:07 +0800 |
commit | fb821731eb12906996bffdf4b3633d7fe47c85a7 (patch) | |
tree | 1388387968d1d719706ddc7164d6426164d01509 | |
parent | 315ae14f3f5c98ae4c4476e4bb260b9086c773a4 (diff) | |
download | bitcoin-fb821731eb12906996bffdf4b3633d7fe47c85a7.tar.xz |
[net processing] ignore tx GETDATA from blocks-only peers
Co-Authored-By: John Newbery <john@johnnewbery.com>
Github-Pull: #18808
Rebased-From: 047ceac142246b5d51056a51dbf4645b31802be4
-rw-r--r-- | src/net_processing.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index d3089c4176..01067e58a6 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1564,15 +1564,13 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm std::vector<CInv> vNotFound; 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 - 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(); + // 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; + // 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); while (it != pfrom->vRecvGetData.end() && (it->type == MSG_TX || it->type == MSG_WITNESS_TX)) { @@ -1582,8 +1580,12 @@ void static ProcessGetData(CNode* pfrom, const CChainParams& chainparams, CConnm if (pfrom->fPauseSend) break; - const CInv &inv = *it; - it++; + const CInv &inv = *it++; + + if (pfrom->m_tx_relay == nullptr) { + // Ignore GETDATA requests for transactions from blocks-only peers. + continue; + } // Send stream from relay memory bool push = false; |