txorphanage: Extract GetOrphanTx

Extract orphan lookup code into GetOrphanTx function.
This commit is contained in:
Anthony Towns
2021-01-31 21:59:57 +10:00
parent 83679ffc60
commit f294da7274
3 changed files with 13 additions and 5 deletions

View File

@@ -2104,10 +2104,9 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
const uint256 orphanHash = *orphan_work_set.begin();
orphan_work_set.erase(orphan_work_set.begin());
auto orphan_it = mapOrphanTransactions.find(orphanHash);
if (orphan_it == mapOrphanTransactions.end()) continue;
const auto [porphanTx, from_peer] = GetOrphanTx(orphanHash);
if (porphanTx == nullptr) continue;
const CTransactionRef porphanTx = orphan_it->second.tx;
const MempoolAcceptResult result = AcceptToMemoryPool(::ChainstateActive(), m_mempool, porphanTx, false /* bypass_limits */);
const TxValidationState& state = result.m_state;
@@ -2124,10 +2123,10 @@ void PeerManagerImpl::ProcessOrphanTx(std::set<uint256>& orphan_work_set)
if (state.IsInvalid()) {
LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s from peer=%d. %s\n",
orphanHash.ToString(),
orphan_it->second.fromPeer,
from_peer,
state.ToString());
// Maybe punish peer that gave us an invalid orphan tx
MaybePunishNodeForTx(orphan_it->second.fromPeer, state);
MaybePunishNodeForTx(from_peer, state);
}
// Has inputs but not accepted to mempool
// Probably non-standard or insufficient fee