0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-03 09:56:38 -05:00

txorphange: Drop redundant originator arg from GetTxToReconsider

This commit is contained in:
Anthony Towns 2022-11-22 01:39:32 +10:00
parent a4fe09973a
commit be2304676b
4 changed files with 8 additions and 11 deletions

View file

@ -2892,10 +2892,9 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
CTransactionRef porphanTx = nullptr; CTransactionRef porphanTx = nullptr;
NodeId from_peer = -1;
bool more = false; bool more = false;
while (CTransactionRef porphanTx = m_orphanage.GetTxToReconsider(peer.m_id, from_peer, more)) { while (CTransactionRef porphanTx = m_orphanage.GetTxToReconsider(peer.m_id, more)) {
const MempoolAcceptResult result = m_chainman.ProcessTransaction(porphanTx); const MempoolAcceptResult result = m_chainman.ProcessTransaction(porphanTx);
const TxValidationState& state = result.m_state; const TxValidationState& state = result.m_state;
const uint256& orphanHash = porphanTx->GetHash(); const uint256& orphanHash = porphanTx->GetHash();
@ -2913,10 +2912,10 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
if (state.IsInvalid()) { if (state.IsInvalid()) {
LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s from peer=%d. %s\n", LogPrint(BCLog::MEMPOOL, " invalid orphan tx %s from peer=%d. %s\n",
orphanHash.ToString(), orphanHash.ToString(),
from_peer, peer.m_id,
state.ToString()); state.ToString());
// Maybe punish peer that gave us an invalid orphan tx // Maybe punish peer that gave us an invalid orphan tx
MaybePunishNodeForTx(from_peer, state); MaybePunishNodeForTx(peer.m_id, 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

View file

@ -89,9 +89,8 @@ FUZZ_TARGET_INIT(txorphan, initialize_orphanage)
}, },
[&] { [&] {
{ {
NodeId originator;
bool more = true; bool more = true;
CTransactionRef ref = orphanage.GetTxToReconsider(peer_id, originator, more); CTransactionRef ref = orphanage.GetTxToReconsider(peer_id, more);
if (!ref) { if (!ref) {
Assert(!more); Assert(!more);
} else { } else {

View file

@ -174,7 +174,7 @@ bool TxOrphanage::HaveTx(const GenTxid& gtxid) const
} }
} }
CTransactionRef TxOrphanage::GetTxToReconsider(NodeId peer, NodeId& originator, bool& more) CTransactionRef TxOrphanage::GetTxToReconsider(NodeId peer, bool& more)
{ {
LOCK(m_mutex); LOCK(m_mutex);
@ -188,7 +188,6 @@ CTransactionRef TxOrphanage::GetTxToReconsider(NodeId peer, NodeId& originator,
const auto orphan_it = m_orphans.find(txid); const auto orphan_it = m_orphans.find(txid);
if (orphan_it != m_orphans.end()) { if (orphan_it != m_orphans.end()) {
more = !work_set.empty(); more = !work_set.empty();
originator = orphan_it->second.fromPeer;
return orphan_it->second.tx; return orphan_it->second.tx;
} }
} }

View file

@ -29,11 +29,11 @@ public:
/** Extract a transaction from a peer's work set /** Extract a transaction from a peer's work set
* Returns nullptr and sets more to false if there are no transactions * Returns nullptr and sets more to false if there are no transactions
* to work on. Otherwise returns the transaction reference, removes * to work on. Otherwise returns the transaction reference, removes
* the transaction from the work set, and populates its arguments with * the transaction from the work set, and sets "more" to indicate
* the originating peer, and whether there are more orphans for this peer * if there are more orphans for this peer
* to work on after this tx. * to work on after this tx.
*/ */
CTransactionRef GetTxToReconsider(NodeId peer, NodeId& originator, bool& more) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex); CTransactionRef GetTxToReconsider(NodeId peer, bool& more) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
/** Erase an orphan by txid */ /** Erase an orphan by txid */
int EraseTx(const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex); int EraseTx(const uint256& txid) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);