diff options
author | Anthony Towns <aj@erisian.com.au> | 2021-01-31 21:59:57 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2021-02-26 23:55:10 +1000 |
commit | f294da727413210fda279afdc206a4dd12046d56 (patch) | |
tree | 2fa630f333aae50b5122e8796151300df0cd03c2 /src/net_processing.cpp | |
parent | 83679ffc600305ec0926fd195ee31c11de2ed613 (diff) |
txorphanage: Extract GetOrphanTx
Extract orphan lookup code into GetOrphanTx function.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r-- | src/net_processing.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index cda177dfe3..4ac50dc1f0 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -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 |