mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
[refactor] change Workspace::m_conflicts and adjacent funcs/structs to use Txid
It's preferable to use type-safe transaction identifiers to avoid confusing txid and wtxid. The next commit will add a reference to this set; we use this opportunity to change it to Txid ahead of time instead of adding new uses of uint256.
This commit is contained in:
parent
60f677375e
commit
158623b8e0
6 changed files with 7 additions and 9 deletions
|
@ -115,11 +115,11 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx,
|
|||
}
|
||||
|
||||
std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
|
||||
const std::set<uint256>& direct_conflicts,
|
||||
const std::set<Txid>& direct_conflicts,
|
||||
const uint256& txid)
|
||||
{
|
||||
for (CTxMemPool::txiter ancestorIt : ancestors) {
|
||||
const uint256& hashAncestor = ancestorIt->GetTx().GetHash();
|
||||
const Txid& hashAncestor = ancestorIt->GetTx().GetHash();
|
||||
if (direct_conflicts.count(hashAncestor)) {
|
||||
return strprintf("%s spends conflicting transaction %s",
|
||||
txid.ToString(),
|
||||
|
|
|
@ -80,7 +80,7 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx, const CTx
|
|||
* @returns error message if the sets intersect, std::nullopt if they are disjoint.
|
||||
*/
|
||||
std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
|
||||
const std::set<uint256>& direct_conflicts,
|
||||
const std::set<Txid>& direct_conflicts,
|
||||
const uint256& txid);
|
||||
|
||||
/** Check that the feerate of the replacement transaction(s) is higher than the feerate of each
|
||||
|
|
|
@ -135,8 +135,6 @@ BOOST_FIXTURE_TEST_CASE(rbf_helper_functions, TestChain100Setup)
|
|||
// Tests for EntriesAndTxidsDisjoint
|
||||
BOOST_CHECK(EntriesAndTxidsDisjoint(empty_set, {tx1->GetHash()}, unused_txid) == std::nullopt);
|
||||
BOOST_CHECK(EntriesAndTxidsDisjoint(set_12_normal, {tx3->GetHash()}, unused_txid) == std::nullopt);
|
||||
// EntriesAndTxidsDisjoint uses txids, not wtxids.
|
||||
BOOST_CHECK(EntriesAndTxidsDisjoint({entry2}, {tx2->GetWitnessHash()}, unused_txid) == std::nullopt);
|
||||
BOOST_CHECK(EntriesAndTxidsDisjoint({entry2}, {tx2->GetHash()}, unused_txid).has_value());
|
||||
BOOST_CHECK(EntriesAndTxidsDisjoint(set_12_normal, {tx1->GetHash()}, unused_txid).has_value());
|
||||
BOOST_CHECK(EntriesAndTxidsDisjoint(set_12_normal, {tx2->GetHash()}, unused_txid).has_value());
|
||||
|
|
|
@ -454,7 +454,7 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
|
|||
cachedInnerUsage += entry.DynamicMemoryUsage();
|
||||
|
||||
const CTransaction& tx = newit->GetTx();
|
||||
std::set<uint256> setParentTransactions;
|
||||
std::set<Txid> setParentTransactions;
|
||||
for (unsigned int i = 0; i < tx.vin.size(); i++) {
|
||||
mapNextTx.insert(std::make_pair(&tx.vin[i].prevout, &tx));
|
||||
setParentTransactions.insert(tx.vin[i].prevout.hash);
|
||||
|
@ -969,7 +969,7 @@ std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
|
|||
return std::nullopt;
|
||||
}
|
||||
|
||||
CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<uint256>& hashes) const
|
||||
CTxMemPool::setEntries CTxMemPool::GetIterSet(const std::set<Txid>& hashes) const
|
||||
{
|
||||
CTxMemPool::setEntries ret;
|
||||
for (const auto& h : hashes) {
|
||||
|
|
|
@ -522,7 +522,7 @@ public:
|
|||
/** Translate a set of hashes into a set of pool iterators to avoid repeated lookups.
|
||||
* Does not require that all of the hashes correspond to actual transactions in the mempool,
|
||||
* only returns the ones that exist. */
|
||||
setEntries GetIterSet(const std::set<uint256>& hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
setEntries GetIterSet(const std::set<Txid>& hashes) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** Translate a list of hashes into a list of mempool iterators to avoid repeated lookups.
|
||||
* The nth element in txids becomes the nth element in the returned vector. If any of the txids
|
||||
|
|
|
@ -582,7 +582,7 @@ private:
|
|||
struct Workspace {
|
||||
explicit Workspace(const CTransactionRef& ptx) : m_ptx(ptx), m_hash(ptx->GetHash()) {}
|
||||
/** Txids of mempool transactions that this transaction directly conflicts with. */
|
||||
std::set<uint256> m_conflicts;
|
||||
std::set<Txid> m_conflicts;
|
||||
/** Iterators to mempool entries that this transaction directly conflicts with. */
|
||||
CTxMemPool::setEntries m_iters_conflicting;
|
||||
/** Iterators to all mempool entries that would be replaced by this transaction, including
|
||||
|
|
Loading…
Add table
Reference in a new issue