mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
[mempool] add GetPrioritisedTransactions
This commit is contained in:
parent
ccd4db7d62
commit
9e9ca36c80
2 changed files with 29 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue