diff options
author | Anthony Towns <aj@erisian.com.au> | 2021-02-25 00:28:16 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2022-10-11 14:05:09 +1000 |
commit | a936f41a5d5f7bb97425f82ec64dfae62e840a56 (patch) | |
tree | a7d8e962139d566375a83ee191af3c204a7e8f0f /src/txorphanage.cpp | |
parent | 3614819864a84ac32f6d53c6ace79b5e71bc174a (diff) |
txorphanage: make m_peer_work_set private
Diffstat (limited to 'src/txorphanage.cpp')
-rw-r--r-- | src/txorphanage.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/txorphanage.cpp b/src/txorphanage.cpp index d26a84b0ef..4cccb1affb 100644 --- a/src/txorphanage.cpp +++ b/src/txorphanage.cpp @@ -167,13 +167,27 @@ bool TxOrphanage::HaveTx(const GenTxid& gtxid) const } } -std::pair<CTransactionRef, NodeId> TxOrphanage::GetTx(const uint256& txid) const +CTransactionRef TxOrphanage::GetTxToReconsider(NodeId peer, NodeId& originator, bool& more) { AssertLockHeld(g_cs_orphans); - const auto it = m_orphans.find(txid); - if (it == m_orphans.end()) return {nullptr, -1}; - return {it->second.tx, it->second.fromPeer}; + auto work_set_it = m_peer_work_set.find(peer); + if (work_set_it != m_peer_work_set.end()) { + auto& work_set = work_set_it->second; + while (!work_set.empty()) { + uint256 txid = *work_set.begin(); + work_set.erase(work_set.begin()); + + const auto orphan_it = m_orphans.find(txid); + if (orphan_it != m_orphans.end()) { + more = !work_set.empty(); + originator = orphan_it->second.fromPeer; + return orphan_it->second.tx; + } + } + } + more = false; + return nullptr; } void TxOrphanage::EraseForBlock(const CBlock& block) |