mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-28 18:01:27 +02:00
[mempool] add GetPrioritisedTransactions
This commit is contained in:
parent
ccd4db7d62
commit
9e9ca36c80
@ -890,6 +890,22 @@ void CTxMemPool::ClearPrioritisation(const uint256& hash)
|
||||
mapDeltas.erase(hash);
|
||||
}
|
||||
|
||||
std::vector<CTxMemPool::delta_info> CTxMemPool::GetPrioritisedTransactions() const
|
||||
{
|
||||
AssertLockNotHeld(cs);
|
||||
LOCK(cs);
|
||||
std::vector<delta_info> result;
|
||||
result.reserve(mapDeltas.size());
|
||||
for (const auto& [txid, delta] : mapDeltas) {
|
||||
const auto iter{mapTx.find(txid)};
|
||||
const bool in_mempool{iter != mapTx.end()};
|
||||
std::optional<CAmount> modified_fee;
|
||||
if (in_mempool) modified_fee = iter->GetModifiedFee();
|
||||
result.emplace_back(delta_info{in_mempool, delta, modified_fee, txid});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const CTransaction* CTxMemPool::GetConflictTx(const COutPoint& prevout) const
|
||||
{
|
||||
const auto it = mapNextTx.find(prevout);
|
||||
|
@ -516,6 +516,19 @@ public:
|
||||
void ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
void ClearPrioritisation(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
struct delta_info {
|
||||
/** Whether this transaction is in the mempool. */
|
||||
const bool in_mempool;
|
||||
/** The fee delta added using PrioritiseTransaction(). */
|
||||
const CAmount delta;
|
||||
/** The modified fee (base fee + delta) of this entry. Only present if in_mempool=true. */
|
||||
std::optional<CAmount> modified_fee;
|
||||
/** The prioritised transaction's txid. */
|
||||
const uint256 txid;
|
||||
};
|
||||
/** Return a vector of all entries in mapDeltas with their corresponding delta_info. */
|
||||
std::vector<delta_info> GetPrioritisedTransactions() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||
|
||||
/** Get the transaction in the pool that spends the same prevout */
|
||||
const CTransaction* GetConflictTx(const COutPoint& prevout) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user