Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 2,985 Lines • ▼ Show 20 Lines | |||||
void PeerManagerImpl::ProcessOrphanTx(const Config &config, | void PeerManagerImpl::ProcessOrphanTx(const Config &config, | ||||
std::set<TxId> &orphan_work_set) { | std::set<TxId> &orphan_work_set) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
AssertLockHeld(g_cs_orphans); | AssertLockHeld(g_cs_orphans); | ||||
while (!orphan_work_set.empty()) { | while (!orphan_work_set.empty()) { | ||||
const TxId orphanTxId = *orphan_work_set.begin(); | const TxId orphanTxId = *orphan_work_set.begin(); | ||||
orphan_work_set.erase(orphan_work_set.begin()); | orphan_work_set.erase(orphan_work_set.begin()); | ||||
auto orphan_it = mapOrphanTransactions.find(orphanTxId); | const auto [porphanTx, from_peer] = GetOrphanTx(orphanTxId); | ||||
if (orphan_it == mapOrphanTransactions.end()) { | if (porphanTx == nullptr) { | ||||
continue; | continue; | ||||
} | } | ||||
const CTransactionRef porphanTx = orphan_it->second.tx; | |||||
TxValidationState state; | TxValidationState state; | ||||
if (AcceptToMemoryPool(::ChainstateActive(), config, m_mempool, state, | if (AcceptToMemoryPool(::ChainstateActive(), config, m_mempool, state, | ||||
porphanTx, false /* bypass_limits */)) { | porphanTx, false /* bypass_limits */)) { | ||||
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", | LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", | ||||
orphanTxId.ToString()); | orphanTxId.ToString()); | ||||
RelayTransaction(orphanTxId, m_connman); | RelayTransaction(orphanTxId, m_connman); | ||||
AddChildrenToWorkSet(*porphanTx, orphan_work_set); | AddChildrenToWorkSet(*porphanTx, orphan_work_set); | ||||
EraseOrphanTx(orphanTxId); | EraseOrphanTx(orphanTxId); | ||||
break; | break; | ||||
} else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) { | } else if (state.GetResult() != TxValidationResult::TX_MISSING_INPUTS) { | ||||
if (state.IsInvalid()) { | if (state.IsInvalid()) { | ||||
LogPrint(BCLog::MEMPOOL, | LogPrint(BCLog::MEMPOOL, | ||||
" invalid orphan tx %s from peer=%d. %s\n", | " invalid orphan tx %s from peer=%d. %s\n", | ||||
orphanTxId.ToString(), orphan_it->second.fromPeer, | orphanTxId.ToString(), from_peer, state.ToString()); | ||||
state.ToString()); | |||||
// Punish peer that gave us an invalid orphan tx | // 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 | // Has inputs but not accepted to mempool | ||||
// Probably non-standard or insufficient fee | // Probably non-standard or insufficient fee | ||||
LogPrint(BCLog::MEMPOOL, " removed orphan tx %s\n", | LogPrint(BCLog::MEMPOOL, " removed orphan tx %s\n", | ||||
orphanTxId.ToString()); | orphanTxId.ToString()); | ||||
assert(recentRejects); | assert(recentRejects); | ||||
recentRejects->insert(orphanTxId); | recentRejects->insert(orphanTxId); | ||||
▲ Show 20 Lines • Show All 3,868 Lines • Show Last 20 Lines |