mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 07:09:15 +01:00
txorphange: move orphan workset to txorphanage
This commit is contained in:
@@ -368,9 +368,6 @@ struct Peer {
|
||||
/** Total number of addresses that were processed (excludes rate-limited ones). */
|
||||
std::atomic<uint64_t> m_addr_processed{0};
|
||||
|
||||
/** Set of txids to reconsider once their parent transactions have been accepted **/
|
||||
std::set<uint256> m_orphan_work_set GUARDED_BY(g_cs_orphans);
|
||||
|
||||
/** Whether we've sent this peer a getheaders in response to an inv prior to initial-headers-sync completing */
|
||||
bool m_inv_triggered_getheaders_before_sync GUARDED_BY(NetEventsInterface::g_msgproc_mutex){false};
|
||||
|
||||
@@ -2890,11 +2887,14 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
|
||||
AssertLockHeld(cs_main);
|
||||
AssertLockHeld(g_cs_orphans);
|
||||
|
||||
if (peer.m_orphan_work_set.empty()) return false;
|
||||
auto work_set_it = m_orphanage.m_peer_work_set.find(peer.m_id);
|
||||
if (work_set_it == m_orphanage.m_peer_work_set.end()) return false;
|
||||
|
||||
while (!peer.m_orphan_work_set.empty()) {
|
||||
const uint256 orphanHash = *peer.m_orphan_work_set.begin();
|
||||
peer.m_orphan_work_set.erase(peer.m_orphan_work_set.begin());
|
||||
std::set<uint256>& orphan_work_set = work_set_it->second;
|
||||
|
||||
while (!orphan_work_set.empty()) {
|
||||
const uint256 orphanHash = *orphan_work_set.begin();
|
||||
orphan_work_set.erase(orphan_work_set.begin());
|
||||
|
||||
const auto [porphanTx, from_peer] = m_orphanage.GetTx(orphanHash);
|
||||
if (porphanTx == nullptr) continue;
|
||||
@@ -2905,7 +2905,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
|
||||
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
|
||||
LogPrint(BCLog::MEMPOOL, " accepted orphan tx %s\n", orphanHash.ToString());
|
||||
RelayTransaction(orphanHash, porphanTx->GetWitnessHash());
|
||||
m_orphanage.AddChildrenToWorkSet(*porphanTx, peer.m_orphan_work_set);
|
||||
m_orphanage.AddChildrenToWorkSet(*porphanTx, peer.m_id);
|
||||
m_orphanage.EraseTx(orphanHash);
|
||||
for (const CTransactionRef& removedTx : result.m_replaced_transactions.value()) {
|
||||
AddToCompactExtraTransactions(removedTx);
|
||||
@@ -2957,7 +2957,7 @@ bool PeerManagerImpl::ProcessOrphanTx(Peer& peer)
|
||||
}
|
||||
}
|
||||
|
||||
return !peer.m_orphan_work_set.empty();
|
||||
return !orphan_work_set.empty();
|
||||
}
|
||||
|
||||
bool PeerManagerImpl::PrepareBlockFilterRequest(CNode& node, Peer& peer,
|
||||
@@ -3950,7 +3950,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||
m_txrequest.ForgetTxHash(tx.GetHash());
|
||||
m_txrequest.ForgetTxHash(tx.GetWitnessHash());
|
||||
RelayTransaction(tx.GetHash(), tx.GetWitnessHash());
|
||||
m_orphanage.AddChildrenToWorkSet(tx, peer->m_orphan_work_set);
|
||||
m_orphanage.AddChildrenToWorkSet(tx, peer->m_id);
|
||||
|
||||
pfrom.m_last_tx_time = GetTime<std::chrono::seconds>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user