Skip to content

Commit

Permalink
mempool: Remove txiter/setEntries from public interface
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCharlatan committed Nov 15, 2023
1 parent fc67919 commit 6bf4437
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <string_view>
#include <utility>

typedef std::set<CTxMemPool::txiter, CompareIteratorByHash> setEntries;

bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
{
AssertLockHeld(cs_main);
Expand Down
19 changes: 9 additions & 10 deletions src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ class CTxMemPool
using txiter = indexed_transaction_set::nth_index<0>::type::const_iterator;
std::vector<CTransactionRef> txns_randomized GUARDED_BY(cs); //!< All transactions in mapTx, in random order

typedef std::set<txiter, CompareIteratorByHash> setEntries;

typedef std::set<CTxMemPoolEntryRef, CompareIteratorByHash> setEntryRefs;

using Limits = kernel::MemPoolLimits;
Expand Down Expand Up @@ -434,6 +432,9 @@ class CTxMemPool
const Limits& limits
) const EXCLUSIVE_LOCKS_REQUIRED(cs);

/** Returns an iterator to the given hash, if found */
std::optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);

public:
indirectmap<COutPoint, const CTransaction*> mapNextTx GUARDED_BY(cs);
std::map<uint256, CAmount> mapDeltas GUARDED_BY(cs);
Expand Down Expand Up @@ -522,9 +523,6 @@ class CTxMemPool
/** Get the transaction in the pool that spends the same prevout */
const CTransaction* GetConflictTx(const COutPoint& prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs);

/** Returns an iterator to the given hash, if found */
std::optional<txiter> GetIter(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);

/** Translate a set of hashes into a set of pool entries 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. */
Expand Down Expand Up @@ -688,11 +686,6 @@ class CTxMemPool
const CTxMemPoolEntry* GetEntry(const Txid& txid) const LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(cs);

CTransactionRef get(const uint256& hash) const;
txiter get_iter_from_wtxid(const uint256& wtxid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
{
AssertLockHeld(cs);
return mapTx.project<0>(mapTx.get<index_by_wtxid>().find(wtxid));
}
TxMempoolInfo info(const GenTxid& gtxid) const;

/** Returns info for a transaction if its entry_sequence < last_sequence */
Expand Down Expand Up @@ -790,6 +783,12 @@ class CTxMemPool
*/
void removeUnchecked(txiter entry, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs);

txiter get_iter_from_wtxid(const uint256& wtxid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
{
AssertLockHeld(cs);
return mapTx.project<0>(mapTx.get<index_by_wtxid>().find(wtxid));
}

/** visited marks a CTxMemPoolEntry as having been traversed
* during the lifetime of the most recently created Epoch::Guard
* and returns false if we are the first visitor, true otherwise.
Expand Down

0 comments on commit 6bf4437

Please sign in to comment.