mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-09-06 20:52:08 +02:00
refactor: miscellaneous GenTxid followups
Addresses a few comments from #32631: https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2199951996 https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2201874252 https://github.com/bitcoin/bitcoin/pull/32631#discussion_r2201918072
This commit is contained in:
@@ -962,9 +962,9 @@ const CTransaction* CTxMemPool::GetConflictTx(const COutPoint& prevout) const
|
|||||||
|
|
||||||
std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const Txid& txid) const
|
std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const Txid& txid) const
|
||||||
{
|
{
|
||||||
|
AssertLockHeld(cs);
|
||||||
auto it = mapTx.find(txid.ToUint256());
|
auto it = mapTx.find(txid.ToUint256());
|
||||||
if (it != mapTx.end()) return it;
|
return it != mapTx.end() ? std::make_optional(it) : std::nullopt;
|
||||||
return std::nullopt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const Wtxid& wtxid) const
|
std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const Wtxid& wtxid) const
|
||||||
|
@@ -98,7 +98,8 @@ public:
|
|||||||
|
|
||||||
friend auto operator<=>(const GenTxid& a, const GenTxid& b)
|
friend auto operator<=>(const GenTxid& a, const GenTxid& b)
|
||||||
{
|
{
|
||||||
return std::tuple(a.IsWtxid(), a.ToUint256()) <=> std::tuple(b.IsWtxid(), b.ToUint256());
|
// Use a reference for read-only access to the hash, avoiding a copy that might not be optimized away.
|
||||||
|
return std::tuple<bool, const uint256&>(a.IsWtxid(), a.ToUint256()) <=> std::tuple<bool, const uint256&>(b.IsWtxid(), b.ToUint256());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user