mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 03:47:29 -03:00
[txorphanage] add GetTx so that orphan vin can be read
This commit is contained in:
parent
e810842acd
commit
04448ce32a
4 changed files with 13 additions and 0 deletions
|
@ -157,5 +157,8 @@ FUZZ_TARGET(txorphan, .init = initialize_orphanage)
|
||||||
ptx_potential_parent = tx;
|
ptx_potential_parent = tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool have_tx{orphanage.HaveTx(tx->GetWitnessHash())};
|
||||||
|
const bool get_tx_nonnull{orphanage.GetTx(tx->GetWitnessHash()) != nullptr};
|
||||||
|
Assert(have_tx == get_tx_nonnull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,9 @@ BOOST_AUTO_TEST_CASE(same_txid_diff_witness)
|
||||||
// EraseTx fails as transaction by this wtxid doesn't exist.
|
// EraseTx fails as transaction by this wtxid doesn't exist.
|
||||||
BOOST_CHECK_EQUAL(orphanage.EraseTx(mutated_wtxid), 0);
|
BOOST_CHECK_EQUAL(orphanage.EraseTx(mutated_wtxid), 0);
|
||||||
BOOST_CHECK(orphanage.HaveTx(normal_wtxid));
|
BOOST_CHECK(orphanage.HaveTx(normal_wtxid));
|
||||||
|
BOOST_CHECK(orphanage.GetTx(normal_wtxid) == child_normal);
|
||||||
BOOST_CHECK(!orphanage.HaveTx(mutated_wtxid));
|
BOOST_CHECK(!orphanage.HaveTx(mutated_wtxid));
|
||||||
|
BOOST_CHECK(orphanage.GetTx(mutated_wtxid) == nullptr);
|
||||||
|
|
||||||
// Must succeed. Both transactions should be present in orphanage.
|
// Must succeed. Both transactions should be present in orphanage.
|
||||||
BOOST_CHECK(orphanage.AddTx(child_mutated, peer));
|
BOOST_CHECK(orphanage.AddTx(child_mutated, peer));
|
||||||
|
|
|
@ -179,6 +179,12 @@ bool TxOrphanage::HaveTx(const Wtxid& wtxid) const
|
||||||
return m_orphans.count(wtxid);
|
return m_orphans.count(wtxid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CTransactionRef TxOrphanage::GetTx(const Wtxid& wtxid) const
|
||||||
|
{
|
||||||
|
auto it = m_orphans.find(wtxid);
|
||||||
|
return it != m_orphans.end() ? it->second.tx : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool TxOrphanage::HaveTxFromPeer(const Wtxid& wtxid, NodeId peer) const
|
bool TxOrphanage::HaveTxFromPeer(const Wtxid& wtxid, NodeId peer) const
|
||||||
{
|
{
|
||||||
auto it = m_orphans.find(wtxid);
|
auto it = m_orphans.find(wtxid);
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
/** Add an additional announcer to an orphan if it exists. Otherwise, do nothing. */
|
/** Add an additional announcer to an orphan if it exists. Otherwise, do nothing. */
|
||||||
bool AddAnnouncer(const Wtxid& wtxid, NodeId peer);
|
bool AddAnnouncer(const Wtxid& wtxid, NodeId peer);
|
||||||
|
|
||||||
|
CTransactionRef GetTx(const Wtxid& wtxid) const;
|
||||||
|
|
||||||
/** Check if we already have an orphan transaction (by wtxid only) */
|
/** Check if we already have an orphan transaction (by wtxid only) */
|
||||||
bool HaveTx(const Wtxid& wtxid) const;
|
bool HaveTx(const Wtxid& wtxid) const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue