aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorSuhas Daftuar <sdaftuar@gmail.com>2019-04-16 15:13:29 -0400
committerSuhas Daftuar <sdaftuar@gmail.com>2019-04-26 09:31:29 -0400
commite32e08407e2781d881b9da92aa06494525ddd085 (patch)
tree87e2a7e7e9885eea8445c6d2f559727e680909b4 /src/net_processing.cpp
parent23163b759354b84c5a076e3e2ae6ae6338106035 (diff)
downloadbitcoin-e32e08407e2781d881b9da92aa06494525ddd085.tar.xz
Remove NOTFOUND transactions from in-flight data structures
This prevents a bug where the in-flight queue for our peers will not be drained, resulting in not downloading any new transactions from our peers. Thanks to ajtowns for reporting this bug.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index f114981cc7..60e16bc413 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -3120,8 +3120,27 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
}
if (strCommand == NetMsgType::NOTFOUND) {
- // We do not care about the NOTFOUND message, but logging an Unknown Command
- // message would be undesirable as we transmit it ourselves.
+ // Remove the NOTFOUND transactions from the peer
+ LOCK(cs_main);
+ CNodeState *state = State(pfrom->GetId());
+ std::vector<CInv> vInv;
+ vRecv >> vInv;
+ if (vInv.size() <= MAX_PEER_TX_IN_FLIGHT + MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
+ for (CInv &inv : vInv) {
+ if (inv.type == MSG_TX || inv.type == MSG_WITNESS_TX) {
+ // If we receive a NOTFOUND message for a txid we requested, erase
+ // it from our data structures for this peer.
+ auto in_flight_it = state->m_tx_download.m_tx_in_flight.find(inv.hash);
+ if (in_flight_it == state->m_tx_download.m_tx_in_flight.end()) {
+ // Skip any further work if this is a spurious NOTFOUND
+ // message.
+ continue;
+ }
+ state->m_tx_download.m_tx_in_flight.erase(in_flight_it);
+ state->m_tx_download.m_tx_announced.erase(inv.hash);
+ }
+ }
+ }
return true;
}