From 9f237e615fb3099f15a7a53676695528ed5ff1c1 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Fri, 31 May 2024 23:00:53 +0000 Subject: [PATCH] fixups. Still not passing tests --- src/txmempool.h | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/txmempool.h b/src/txmempool.h index 17e54a38b61a5..940d56faf6a0d 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -432,23 +432,7 @@ class MempoolContainer return m_wtxid_map; } } -/* - template - const_iterator project(const T& from) const - { - static_assert(to == 0); - // if constexpr (std::is_same_v) { - // return m_descendent_order.find(from); - // } else - if constexpr (std::is_same_v) { - //TODO check - return m_wtxid_map.find(from->first)->second; - } else if constexpr (std::is_same_v) { - return m_time_order.find(from); - } - //return m_entries.end(); - } -*/ + size_t size() const { return m_entries.size(); @@ -464,8 +448,7 @@ class MempoolContainer template std::pair emplace(Args&&... args) { - m_entries.emplace_back(std::forward(args)...); - auto new_it = m_entries.end(); + auto new_it = m_entries.emplace(m_entries.end(), std::forward(args)...); m_txid_map.emplace(new_it->GetTx().GetHash(), new_it); m_wtxid_map.emplace(new_it->GetTx().GetWitnessHash(), new_it); m_descendent_order.insert(new_it); @@ -497,8 +480,8 @@ class MempoolContainer const_iterator iterator_to(const entry_type& entry) const { - auto it = m_txid_map.find(entry.GetTx().GetHash()); - if (it == m_txid_map.end()) return m_entries.end(); + auto it = m_wtxid_map.find(entry.GetTx().GetWitnessHash()); + if (it == m_wtxid_map.end()) return m_entries.end(); return it->second; } @@ -522,14 +505,9 @@ class MempoolContainer const_iterator get_iter_from_wtxid(const uint256& wtxid) const { auto it = m_wtxid_map.find(wtxid); + if(it == m_wtxid_map.end()) return m_entries.end(); return it->second; } -/* - const_iterator get_iter_from_entry_time(time_order_type::const_iterator it) const - { - return m_time_order.find(it); - } -*/ }; class CTxMemPool