Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tidy up ProcessOrphanTx #19498

Merged
merged 6 commits into from
Sep 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ProcessOrphanTx: remove useless setMisbehaving set
This starts empty, and is only added to if we're about to
exit the function (so we never read from it).
  • Loading branch information
jnewbery committed Sep 7, 2020
commit 4763b51bca86fb9e49175619a47cdbef34feaf99
8 changes: 2 additions & 6 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,6 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<
{
AssertLockHeld(cs_main);
AssertLockHeld(g_cs_orphans);
std::set<NodeId> setMisbehaving;

while (!orphan_work_set.empty()) {
const uint256 orphanHash = *orphan_work_set.begin();
Expand All @@ -2065,7 +2064,6 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<
// that relayed the previous transaction).
TxValidationState orphan_state;

if (setMisbehaving.count(fromPeer)) continue;
if (AcceptToMemoryPool(m_mempool, orphan_state, porphanTx, &removed_txn, false /* bypass_limits */, 0 /* nAbsurdFee */)) {
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
RelayTransaction(orphanHash, porphanTx->GetWitnessHash(), m_connman);
Expand All @@ -2081,14 +2079,12 @@ void PeerManager::ProcessOrphanTx(std::set<uint256>& orphan_work_set, std::list<
break;
} else if (orphan_state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) {
if (orphan_state.IsInvalid()) {
// Punish peer that gave us an invalid orphan tx
if (MaybePunishNodeForTx(fromPeer, orphan_state)) {
setMisbehaving.insert(fromPeer);
}
LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s from peer=%d. %s\n",
orphanHash.ToString(),
fromPeer,
orphan_state.ToString());
// Maybe punish peer that gave us an invalid orphan tx
MaybePunishNodeForTx(fromPeer, orphan_state);
}
// Has inputs but not accepted to mempool
// Probably non-standard or insufficient fee
Expand Down