@@ -802,14 +802,14 @@ bool CTxMemPool::CompareDepthAndScore(const uint256& hasha, const uint256& hashb
802
802
* both are in the mempool and a has a higher score than b
803
803
*/
804
804
LOCK (cs);
805
- indexed_transaction_set::const_iterator j = wtxid ? get_iter_from_wtxid ( hashb) : mapTx. find ( hashb);
806
- if (j == mapTx. end ()) return false ;
807
- indexed_transaction_set::const_iterator i = wtxid ? get_iter_from_wtxid ( hasha) : mapTx. find ( hasha);
808
- if (i == mapTx. end ()) return true ;
809
- uint64_t counta = i->GetCountWithAncestors ();
810
- uint64_t countb = j->GetCountWithAncestors ();
805
+ auto j = wtxid ? GetIter ( Wtxid::FromUint256 ( hashb)) : GetIter ( Txid::FromUint256 ( hashb) );
806
+ if (!j. has_value ()) return false ;
807
+ auto i = wtxid ? GetIter ( Wtxid::FromUint256 ( hasha)) : GetIter ( Txid::FromUint256 ( hasha) );
808
+ if (!i. has_value ()) return true ;
809
+ uint64_t counta = i. value () ->GetCountWithAncestors ();
810
+ uint64_t countb = j. value () ->GetCountWithAncestors ();
811
811
if (counta == countb) {
812
- return CompareTxMemPoolEntryByScore ()(*i, *j);
812
+ return CompareTxMemPoolEntryByScore ()(*i. value () , *j. value () );
813
813
}
814
814
return counta < countb;
815
815
}
@@ -893,18 +893,16 @@ CTransactionRef CTxMemPool::get(const uint256& hash) const
893
893
TxMempoolInfo CTxMemPool::info (const GenTxid& gtxid) const
894
894
{
895
895
LOCK (cs);
896
- indexed_transaction_set::const_iterator i = (gtxid.IsWtxid () ? get_iter_from_wtxid (gtxid.GetHash ()) : mapTx.find (gtxid.GetHash ()));
897
- if (i == mapTx.end ())
898
- return TxMempoolInfo ();
899
- return GetInfo (i);
896
+ auto i = (gtxid.IsWtxid () ? GetIter (Wtxid::FromUint256 (gtxid.GetHash ())) : GetIter (Txid::FromUint256 (gtxid.GetHash ())));
897
+ return i.has_value () ? GetInfo (*i) : TxMempoolInfo{};
900
898
}
901
899
902
900
TxMempoolInfo CTxMemPool::info_for_relay (const GenTxid& gtxid, uint64_t last_sequence) const
903
901
{
904
902
LOCK (cs);
905
- indexed_transaction_set::const_iterator i = (gtxid.IsWtxid () ? get_iter_from_wtxid ( gtxid.GetHash ()) : mapTx. find ( gtxid.GetHash ()));
906
- if (i != mapTx. end () && i ->GetSequence () < last_sequence) {
907
- return GetInfo (i);
903
+ auto i = (gtxid.IsWtxid () ? GetIter ( Wtxid::FromUint256 ( gtxid.GetHash ())) : GetIter ( Txid::FromUint256 ( gtxid.GetHash () )));
904
+ if (i. has_value () && (*i) ->GetSequence () < last_sequence) {
905
+ return GetInfo (* i);
908
906
} else {
909
907
return TxMempoolInfo ();
910
908
}
@@ -991,6 +989,13 @@ std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const Txid& txid) const
991
989
return std::nullopt;
992
990
}
993
991
992
+ std::optional<CTxMemPool::txiter> CTxMemPool::GetIter (const Wtxid& wtxid) const
993
+ {
994
+ AssertLockHeld (cs);
995
+ auto it{mapTx.project <0 >(mapTx.get <index_by_wtxid>().find (wtxid))};
996
+ return it != mapTx.end () ? std::make_optional (it) : std::nullopt;
997
+ }
998
+
994
999
CTxMemPool::setEntries CTxMemPool::GetIterSet (const std::set<Txid>& hashes) const
995
1000
{
996
1001
CTxMemPool::setEntries ret;
0 commit comments