mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-06-03 16:02:34 +02:00
CTxMemPool::FindScriptPubKey to search unconfirmed UTXOs
This commit is contained in:
parent
401bfc1752
commit
d5f9eea818
@ -803,6 +803,21 @@ std::vector<CTxMemPool::indexed_transaction_set::const_iterator> CTxMemPool::Get
|
||||
return iters;
|
||||
}
|
||||
|
||||
void CTxMemPool::FindScriptPubKey(const std::set<CScript>& needles, std::map<COutPoint, Coin>& out_results) {
|
||||
LOCK(cs);
|
||||
for (const CTxMemPoolEntry& entry : mapTx) {
|
||||
const CTransaction& tx = entry.GetTx();
|
||||
const Txid& hash = tx.GetHash();
|
||||
for (size_t txo_index = tx.vout.size(); txo_index > 0; ) {
|
||||
--txo_index;
|
||||
const CTxOut& txo = tx.vout[txo_index];
|
||||
if (needles.count(txo.scriptPubKey)) {
|
||||
out_results.emplace(COutPoint(hash, txo_index), Coin(txo, MEMPOOL_HEIGHT, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
|
||||
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()};
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include <vector>
|
||||
|
||||
class CChain;
|
||||
class CScript;
|
||||
|
||||
/** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */
|
||||
static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
|
||||
@ -696,6 +697,8 @@ public:
|
||||
std::vector<CTxMemPoolEntryRef> entryAll() const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
std::vector<TxMempoolInfo> infoAll() const;
|
||||
|
||||
void FindScriptPubKey(const std::set<CScript>& needles, std::map<COutPoint, Coin>& out_results);
|
||||
|
||||
size_t DynamicMemoryUsage() const;
|
||||
|
||||
/** Adds a transaction to the unbroadcast set */
|
||||
|
Loading…
Reference in New Issue
Block a user