Skip to content

Commit e32e084

Browse files
committed
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.
1 parent 23163b7 commit e32e084

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/net_processing.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,8 +3120,27 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
31203120
}
31213121

31223122
if (strCommand == NetMsgType::NOTFOUND) {
3123-
// We do not care about the NOTFOUND message, but logging an Unknown Command
3124-
// message would be undesirable as we transmit it ourselves.
3123+
// Remove the NOTFOUND transactions from the peer
3124+
LOCK(cs_main);
3125+
CNodeState *state = State(pfrom->GetId());
3126+
std::vector<CInv> vInv;
3127+
vRecv >> vInv;
3128+
if (vInv.size() <= MAX_PEER_TX_IN_FLIGHT + MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
3129+
for (CInv &inv : vInv) {
3130+
if (inv.type == MSG_TX || inv.type == MSG_WITNESS_TX) {
3131+
// If we receive a NOTFOUND message for a txid we requested, erase
3132+
// it from our data structures for this peer.
3133+
auto in_flight_it = state->m_tx_download.m_tx_in_flight.find(inv.hash);
3134+
if (in_flight_it == state->m_tx_download.m_tx_in_flight.end()) {
3135+
// Skip any further work if this is a spurious NOTFOUND
3136+
// message.
3137+
continue;
3138+
}
3139+
state->m_tx_download.m_tx_in_flight.erase(in_flight_it);
3140+
state->m_tx_download.m_tx_announced.erase(inv.hash);
3141+
}
3142+
}
3143+
}
31253144
return true;
31263145
}
31273146

0 commit comments

Comments
 (0)