mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
mempool, refactor: Convert uint256 to Txid
This commit is contained in:
parent
8b6f9e3365
commit
e78e3764f1
17 changed files with 68 additions and 68 deletions
|
@ -207,10 +207,10 @@ public:
|
|||
virtual RBFTransactionState isRBFOptIn(const CTransaction& tx) = 0;
|
||||
|
||||
//! Check if transaction is in mempool.
|
||||
virtual bool isInMempool(const uint256& txid) = 0;
|
||||
virtual bool isInMempool(const Txid& txid) = 0;
|
||||
|
||||
//! Check if transaction has descendants in mempool.
|
||||
virtual bool hasDescendantsInMempool(const uint256& txid) = 0;
|
||||
virtual bool hasDescendantsInMempool(const Txid& txid) = 0;
|
||||
|
||||
//! Transaction is added to memory pool, if the transaction fee is below the
|
||||
//! amount specified by max_tx_fee, and broadcast to all peers if relay is set to true.
|
||||
|
@ -221,7 +221,7 @@ public:
|
|||
std::string& err_string) = 0;
|
||||
|
||||
//! Calculate mempool ancestor and descendant counts for the given transaction.
|
||||
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) = 0;
|
||||
virtual void getTransactionAncestry(const Txid& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) = 0;
|
||||
|
||||
//! For each outpoint, calculate the fee-bumping cost to spend this outpoint at the specified
|
||||
// feerate, including bumping its ancestors. For example, if the target feerate is 10sat/vbyte
|
||||
|
|
|
@ -1545,13 +1545,13 @@ void PeerManagerImpl::InitializeNode(const CNode& node, ServiceFlags our_service
|
|||
|
||||
void PeerManagerImpl::ReattemptInitialBroadcast(CScheduler& scheduler)
|
||||
{
|
||||
std::set<uint256> unbroadcast_txids = m_mempool.GetUnbroadcastTxs();
|
||||
std::set<Txid> unbroadcast_txids = m_mempool.GetUnbroadcastTxs();
|
||||
|
||||
for (const auto& txid : unbroadcast_txids) {
|
||||
CTransactionRef tx = m_mempool.get(txid);
|
||||
|
||||
if (tx != nullptr) {
|
||||
RelayTransaction(Txid::FromUint256(txid), tx->GetWitnessHash());
|
||||
RelayTransaction(txid, tx->GetWitnessHash());
|
||||
} else {
|
||||
m_mempool.RemoveUnbroadcastTx(txid, true);
|
||||
}
|
||||
|
|
|
@ -669,17 +669,17 @@ public:
|
|||
LOCK(m_node.mempool->cs);
|
||||
return IsRBFOptIn(tx, *m_node.mempool);
|
||||
}
|
||||
bool isInMempool(const uint256& txid) override
|
||||
bool isInMempool(const Txid& txid) override
|
||||
{
|
||||
if (!m_node.mempool) return false;
|
||||
LOCK(m_node.mempool->cs);
|
||||
return m_node.mempool->exists(Txid::FromUint256(txid));
|
||||
return m_node.mempool->exists(txid);
|
||||
}
|
||||
bool hasDescendantsInMempool(const uint256& txid) override
|
||||
bool hasDescendantsInMempool(const Txid& txid) override
|
||||
{
|
||||
if (!m_node.mempool) return false;
|
||||
LOCK(m_node.mempool->cs);
|
||||
const auto entry{m_node.mempool->GetEntry(Txid::FromUint256(txid))};
|
||||
const auto entry{m_node.mempool->GetEntry(txid)};
|
||||
if (entry == nullptr) return false;
|
||||
return entry->GetCountWithDescendants() > 1;
|
||||
}
|
||||
|
@ -694,7 +694,7 @@ public:
|
|||
// that Chain clients do not need to know about.
|
||||
return TransactionError::OK == err;
|
||||
}
|
||||
void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize, CAmount* ancestorfees) override
|
||||
void getTransactionAncestry(const Txid& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize, CAmount* ancestorfees) override
|
||||
{
|
||||
ancestors = descendants = 0;
|
||||
if (!m_node.mempool) return;
|
||||
|
|
|
@ -118,7 +118,7 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
|
|||
if (active_chainstate.m_chainman.m_interrupt)
|
||||
return false;
|
||||
}
|
||||
std::map<uint256, CAmount> mapDeltas;
|
||||
std::map<Txid, CAmount> mapDeltas;
|
||||
file >> mapDeltas;
|
||||
|
||||
if (opts.apply_fee_delta_priority) {
|
||||
|
@ -127,7 +127,7 @@ bool LoadMempool(CTxMemPool& pool, const fs::path& load_path, Chainstate& active
|
|||
}
|
||||
}
|
||||
|
||||
std::set<uint256> unbroadcast_txids;
|
||||
std::set<Txid> unbroadcast_txids;
|
||||
file >> unbroadcast_txids;
|
||||
if (opts.apply_unbroadcast_set) {
|
||||
unbroadcast = unbroadcast_txids.size();
|
||||
|
@ -150,9 +150,9 @@ bool DumpMempool(const CTxMemPool& pool, const fs::path& dump_path, FopenFn mock
|
|||
{
|
||||
auto start = SteadyClock::now();
|
||||
|
||||
std::map<uint256, CAmount> mapDeltas;
|
||||
std::map<Txid, CAmount> mapDeltas;
|
||||
std::vector<TxMempoolInfo> vinfo;
|
||||
std::set<uint256> unbroadcast_txids;
|
||||
std::set<Txid> unbroadcast_txids;
|
||||
|
||||
static Mutex dump_mutex;
|
||||
LOCK(dump_mutex);
|
||||
|
|
|
@ -123,7 +123,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
|
|||
return TransactionError::OK;
|
||||
}
|
||||
|
||||
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, uint256& hashBlock, const BlockManager& blockman)
|
||||
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const Txid& hash, uint256& hashBlock, const BlockManager& blockman)
|
||||
{
|
||||
if (mempool && !block_index) {
|
||||
CTransactionRef ptx = mempool->get(hash);
|
||||
|
|
|
@ -63,7 +63,7 @@ static const CAmount DEFAULT_MAX_BURN_AMOUNT{0};
|
|||
* @param[out] hashBlock The block hash, if the tx was found via -txindex or block_index
|
||||
* @returns The tx if found, otherwise nullptr
|
||||
*/
|
||||
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, uint256& hashBlock, const BlockManager& blockman);
|
||||
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const Txid& hash, uint256& hashBlock, const BlockManager& blockman);
|
||||
} // namespace node
|
||||
|
||||
#endif // BITCOIN_NODE_TRANSACTION_H
|
||||
|
|
|
@ -709,7 +709,7 @@ static bool rest_tx(const std::any& context, HTTPRequest* req, const std::string
|
|||
std::string hashStr;
|
||||
const RESTResponseFormat rf = ParseDataFormat(hashStr, strURIPart);
|
||||
|
||||
auto hash{uint256::FromHex(hashStr)};
|
||||
auto hash{Txid::FromHex(hashStr)};
|
||||
if (!hash) {
|
||||
return RESTERR(req, HTTP_BAD_REQUEST, "Invalid hash: " + hashStr);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
|
|||
AddToMempool(pool, entry.FromTx(block.vtx[2]));
|
||||
BOOST_CHECK_EQUAL(pool.get(block.vtx[2]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);
|
||||
|
||||
uint256 txhash;
|
||||
Txid txhash;
|
||||
|
||||
// Test with pre-forwarding tx 1, but not coinbase
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
|
|||
AddToMempool(pool, entry.FromTx(block.vtx[1]));
|
||||
BOOST_CHECK_EQUAL(pool.get(block.vtx[1]->GetHash()).use_count(), SHARED_TX_OFFSET + 0);
|
||||
|
||||
uint256 txhash;
|
||||
Txid txhash;
|
||||
|
||||
// Test with pre-forwarding coinbase + tx 2 with tx 1 in mempool
|
||||
{
|
||||
|
|
|
@ -313,7 +313,7 @@ FUZZ_TARGET(ephemeral_package_eval, .init = initialize_tx_pool)
|
|||
if (tx_pool.exists(txid)) {
|
||||
const auto tx_info{tx_pool.info(txid)};
|
||||
if (GetDust(*tx_info.tx, tx_pool.m_opts.dust_relay_feerate).empty()) {
|
||||
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
|
||||
tx_pool.PrioritiseTransaction(txid, delta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ FUZZ_TARGET(tx_package_eval, .init = initialize_tx_pool)
|
|||
txs.back()->GetHash() :
|
||||
PickValue(fuzzed_data_provider, mempool_outpoints).hash;
|
||||
const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
|
||||
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
|
||||
tx_pool.PrioritiseTransaction(txid, delta);
|
||||
}
|
||||
|
||||
// Remember all added transactions
|
||||
|
|
|
@ -160,7 +160,7 @@ FUZZ_TARGET(package_rbf, .init = initialize_package_rbf)
|
|||
}
|
||||
|
||||
if (fuzzed_data_provider.ConsumeBool()) {
|
||||
pool.PrioritiseTransaction(mempool_txs.back().GetHash().ToUint256(), fuzzed_data_provider.ConsumeIntegralInRange<int32_t>(-100000, 100000));
|
||||
pool.PrioritiseTransaction(mempool_txs.back().GetHash(), fuzzed_data_provider.ConsumeIntegralInRange<int32_t>(-100000, 100000));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
|
|||
tx->GetHash() :
|
||||
PickValue(fuzzed_data_provider, outpoints_rbf).hash;
|
||||
const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
|
||||
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
|
||||
tx_pool.PrioritiseTransaction(txid, delta);
|
||||
}
|
||||
|
||||
// Remember all removed and added transactions
|
||||
|
@ -408,7 +408,7 @@ FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
|
|||
mut_tx.GetHash() :
|
||||
PickValue(fuzzed_data_provider, txids);
|
||||
const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
|
||||
tx_pool.PrioritiseTransaction(txid.ToUint256(), delta);
|
||||
tx_pool.PrioritiseTransaction(txid, delta);
|
||||
}
|
||||
|
||||
const auto tx = MakeTransactionRef(mut_tx);
|
||||
|
|
|
@ -591,7 +591,7 @@ void MinerTestingSetup::TestPrioritisedMining(const CScript& scriptPubKey, const
|
|||
tx.vin[0].scriptSig = CScript() << OP_1;
|
||||
tx.vout.resize(1);
|
||||
tx.vout[0].nValue = 5000000000LL; // 0 fee
|
||||
uint256 hashFreePrioritisedTx = tx.GetHash();
|
||||
Txid hashFreePrioritisedTx = tx.GetHash();
|
||||
AddToMempool(tx_mempool, entry.Fee(0).Time(Now<NodeSeconds>()).SpendsCoinbase(true).FromTx(tx));
|
||||
tx_mempool.PrioritiseTransaction(hashFreePrioritisedTx, 5 * COIN);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
|||
// added to the mempool by their associate fee
|
||||
// txHashes[j] is populated with transactions either of
|
||||
// fee = basefee * (j+1)
|
||||
std::vector<uint256> txHashes[10];
|
||||
std::vector<Txid> txHashes[10];
|
||||
|
||||
// Create a transaction template
|
||||
CScript garbage;
|
||||
|
@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
|||
/*has_no_mempool_parents=*/true)};
|
||||
m_node.validation_signals->TransactionAddedToMempool(tx_info, mpool.GetAndIncrementSequence());
|
||||
}
|
||||
uint256 hash = tx.GetHash();
|
||||
Txid hash = tx.GetHash();
|
||||
txHashes[j].push_back(hash);
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
|||
/*has_no_mempool_parents=*/true)};
|
||||
m_node.validation_signals->TransactionAddedToMempool(tx_info, mpool.GetAndIncrementSequence());
|
||||
}
|
||||
uint256 hash = tx.GetHash();
|
||||
Txid hash = tx.GetHash();
|
||||
txHashes[j].push_back(hash);
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
|||
/*has_no_mempool_parents=*/true)};
|
||||
m_node.validation_signals->TransactionAddedToMempool(tx_info, mpool.GetAndIncrementSequence());
|
||||
}
|
||||
uint256 hash = tx.GetHash();
|
||||
Txid hash = tx.GetHash();
|
||||
CTransactionRef ptx = mpool.get(hash);
|
||||
if (ptx)
|
||||
block.push_back(ptx);
|
||||
|
|
|
@ -304,7 +304,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
|
||||
Package package_v3_v2{mempool_tx_v3, tx_v2_from_v3};
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v2_from_v3, GetVirtualTransactionSize(*tx_v2_from_v3), package_v3_v2, empty_ancestors), expected_error_str);
|
||||
CTxMemPool::setEntries entries_mempool_v3{pool.GetIter(mempool_tx_v3->GetHash().ToUint256()).value()};
|
||||
CTxMemPool::setEntries entries_mempool_v3{pool.GetIter(mempool_tx_v3->GetHash()).value()};
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v2_from_v3, GetVirtualTransactionSize(*tx_v2_from_v3), {tx_v2_from_v3}, entries_mempool_v3), expected_error_str);
|
||||
|
||||
// mempool_tx_v3 mempool_tx_v2
|
||||
|
@ -339,7 +339,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
|
||||
Package package_v2_v3{mempool_tx_v2, tx_v3_from_v2};
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v3_from_v2, GetVirtualTransactionSize(*tx_v3_from_v2), package_v2_v3, empty_ancestors), expected_error_str);
|
||||
CTxMemPool::setEntries entries_mempool_v2{pool.GetIter(mempool_tx_v2->GetHash().ToUint256()).value()};
|
||||
CTxMemPool::setEntries entries_mempool_v2{pool.GetIter(mempool_tx_v2->GetHash()).value()};
|
||||
BOOST_CHECK_EQUAL(*PackageTRUCChecks(tx_v3_from_v2, GetVirtualTransactionSize(*tx_v3_from_v2), {tx_v3_from_v2}, entries_mempool_v2), expected_error_str);
|
||||
|
||||
// mempool_tx_v3 mempool_tx_v2
|
||||
|
@ -536,7 +536,7 @@ BOOST_FIXTURE_TEST_CASE(version3_tests, RegTestingSetup)
|
|||
// Configuration where parent already has 2 other children in mempool (no sibling eviction allowed). This may happen as the result of a reorg.
|
||||
AddToMempool(pool, entry.FromTx(tx_v3_child2));
|
||||
auto tx_v3_child3 = make_tx({COutPoint{mempool_tx_v3->GetHash(), 24}}, /*version=*/3);
|
||||
auto entry_mempool_parent = pool.GetIter(mempool_tx_v3->GetHash().ToUint256()).value();
|
||||
auto entry_mempool_parent = pool.GetIter(mempool_tx_v3->GetHash()).value();
|
||||
BOOST_CHECK_EQUAL(entry_mempool_parent->GetCountWithDescendants(), 3);
|
||||
auto ancestors_2siblings{pool.CalculateMemPoolAncestors(entry.FromTx(tx_v3_child3), m_limits)};
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp)
|
|||
}
|
||||
|
||||
void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendants,
|
||||
const std::set<uint256>& setExclude, std::set<uint256>& descendants_to_remove)
|
||||
const std::set<Txid>& setExclude, std::set<Txid>& descendants_to_remove)
|
||||
{
|
||||
CTxMemPoolEntry::Children stageEntries, descendants;
|
||||
stageEntries = updateIt->GetMemPoolChildrenConst();
|
||||
|
@ -105,7 +105,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
|
|||
mapTx.modify(updateIt, [=](CTxMemPoolEntry& e) { e.UpdateDescendantState(modifySize, modifyFee, modifyCount); });
|
||||
}
|
||||
|
||||
void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256>& vHashesToUpdate)
|
||||
void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<Txid>& vHashesToUpdate)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
// For each entry in vHashesToUpdate, store the set of in-mempool, but not
|
||||
|
@ -115,29 +115,29 @@ void CTxMemPool::UpdateTransactionsFromBlock(const std::vector<uint256>& vHashes
|
|||
|
||||
// Use a set for lookups into vHashesToUpdate (these entries are already
|
||||
// accounted for in the state of their ancestors)
|
||||
std::set<uint256> setAlreadyIncluded(vHashesToUpdate.begin(), vHashesToUpdate.end());
|
||||
std::set<Txid> setAlreadyIncluded(vHashesToUpdate.begin(), vHashesToUpdate.end());
|
||||
|
||||
std::set<uint256> descendants_to_remove;
|
||||
std::set<Txid> descendants_to_remove;
|
||||
|
||||
// Iterate in reverse, so that whenever we are looking at a transaction
|
||||
// we are sure that all in-mempool descendants have already been processed.
|
||||
// This maximizes the benefit of the descendant cache and guarantees that
|
||||
// CTxMemPoolEntry::m_children will be updated, an assumption made in
|
||||
// UpdateForDescendants.
|
||||
for (const uint256& hash : vHashesToUpdate | std::views::reverse) {
|
||||
for (const Txid& hash : vHashesToUpdate | std::views::reverse) {
|
||||
// calculate children from mapNextTx
|
||||
txiter it = mapTx.find(hash);
|
||||
if (it == mapTx.end()) {
|
||||
continue;
|
||||
}
|
||||
auto iter = mapNextTx.lower_bound(COutPoint(Txid::FromUint256(hash), 0));
|
||||
auto iter = mapNextTx.lower_bound(COutPoint(hash, 0));
|
||||
// First calculate the children, and update CTxMemPoolEntry::m_children to
|
||||
// include them, and update their CTxMemPoolEntry::m_parents to include this tx.
|
||||
// we cache the in-mempool children to avoid duplicate updates
|
||||
{
|
||||
WITH_FRESH_EPOCH(m_epoch);
|
||||
for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) {
|
||||
const uint256 &childHash = iter->second->GetHash();
|
||||
const Txid &childHash = iter->second->GetHash();
|
||||
txiter childIter = mapTx.find(childHash);
|
||||
assert(childIter != mapTx.end());
|
||||
// We can skip updating entries we've encountered before or that
|
||||
|
@ -782,7 +782,7 @@ void CTxMemPool::check(const CCoinsViewCache& active_coins_tip, int64_t spendhei
|
|||
AddCoins(mempoolDuplicate, tx, std::numeric_limits<int>::max());
|
||||
}
|
||||
for (auto it = mapNextTx.cbegin(); it != mapNextTx.cend(); it++) {
|
||||
uint256 hash = it->second->GetHash();
|
||||
Txid hash = it->second->GetHash();
|
||||
indexed_transaction_set::const_iterator it2 = mapTx.find(hash);
|
||||
const CTransaction& tx = it2->GetTx();
|
||||
assert(it2 != mapTx.end());
|
||||
|
@ -889,7 +889,7 @@ const CTxMemPoolEntry* CTxMemPool::GetEntry(const Txid& txid) const
|
|||
return i == mapTx.end() ? nullptr : &(*i);
|
||||
}
|
||||
|
||||
CTransactionRef CTxMemPool::get(const uint256& hash) const
|
||||
CTransactionRef CTxMemPool::get(const Txid& hash) const
|
||||
{
|
||||
LOCK(cs);
|
||||
indexed_transaction_set::const_iterator i = mapTx.find(hash);
|
||||
|
@ -926,7 +926,7 @@ TxMempoolInfo CTxMemPool::info_for_relay(const GenTxid& gtxid, uint64_t last_seq
|
|||
}
|
||||
}
|
||||
|
||||
void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta)
|
||||
void CTxMemPool::PrioritiseTransaction(const Txid& hash, const CAmount& nFeeDelta)
|
||||
{
|
||||
{
|
||||
LOCK(cs);
|
||||
|
@ -962,17 +962,17 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
|
|||
}
|
||||
}
|
||||
|
||||
void CTxMemPool::ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const
|
||||
void CTxMemPool::ApplyDelta(const Txid& hash, CAmount &nFeeDelta) const
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
std::map<uint256, CAmount>::const_iterator pos = mapDeltas.find(hash);
|
||||
std::map<Txid, CAmount>::const_iterator pos = mapDeltas.find(hash);
|
||||
if (pos == mapDeltas.end())
|
||||
return;
|
||||
const CAmount &delta = pos->second;
|
||||
nFeeDelta += delta;
|
||||
}
|
||||
|
||||
void CTxMemPool::ClearPrioritisation(const uint256& hash)
|
||||
void CTxMemPool::ClearPrioritisation(const Txid& hash)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
mapDeltas.erase(hash);
|
||||
|
@ -1000,7 +1000,7 @@ const CTransaction* CTxMemPool::GetConflictTx(const COutPoint& prevout) const
|
|||
return it == mapNextTx.end() ? nullptr : it->second;
|
||||
}
|
||||
|
||||
std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const uint256& txid) const
|
||||
std::optional<CTxMemPool::txiter> CTxMemPool::GetIter(const Txid& txid) const
|
||||
{
|
||||
auto it = mapTx.find(txid);
|
||||
if (it != mapTx.end()) return it;
|
||||
|
@ -1082,7 +1082,7 @@ size_t CTxMemPool::DynamicMemoryUsage() const {
|
|||
return memusage::MallocUsage(sizeof(CTxMemPoolEntry) + 15 * sizeof(void*)) * mapTx.size() + memusage::DynamicUsage(mapNextTx) + memusage::DynamicUsage(mapDeltas) + memusage::DynamicUsage(txns_randomized) + cachedInnerUsage;
|
||||
}
|
||||
|
||||
void CTxMemPool::RemoveUnbroadcastTx(const uint256& txid, const bool unchecked) {
|
||||
void CTxMemPool::RemoveUnbroadcastTx(const Txid& txid, const bool unchecked) {
|
||||
LOCK(cs);
|
||||
|
||||
if (m_unbroadcast_txids.erase(txid))
|
||||
|
@ -1237,7 +1237,7 @@ uint64_t CTxMemPool::CalculateDescendantMaximum(txiter entry) const {
|
|||
return maximum;
|
||||
}
|
||||
|
||||
void CTxMemPool::GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* const ancestorsize, CAmount* const ancestorfees) const {
|
||||
void CTxMemPool::GetTransactionAncestry(const Txid& txid, size_t& ancestors, size_t& descendants, size_t* const ancestorsize, CAmount* const ancestorfees) const {
|
||||
LOCK(cs);
|
||||
auto it = mapTx.find(txid);
|
||||
ancestors = descendants = 0;
|
||||
|
|
|
@ -58,7 +58,7 @@ bool TestLockPointValidity(CChain& active_chain, const LockPoints& lp) EXCLUSIVE
|
|||
// extracts a transaction hash from CTxMemPoolEntry or CTransactionRef
|
||||
struct mempoolentry_txid
|
||||
{
|
||||
typedef uint256 result_type;
|
||||
typedef Txid result_type;
|
||||
result_type operator() (const CTxMemPoolEntry &entry) const
|
||||
{
|
||||
return entry.GetTx().GetHash();
|
||||
|
@ -73,7 +73,7 @@ struct mempoolentry_txid
|
|||
// extracts a transaction witness-hash from CTxMemPoolEntry or CTransactionRef
|
||||
struct mempoolentry_wtxid
|
||||
{
|
||||
typedef uint256 result_type;
|
||||
typedef Wtxid result_type;
|
||||
result_type operator() (const CTxMemPoolEntry &entry) const
|
||||
{
|
||||
return entry.GetTx().GetWitnessHash();
|
||||
|
@ -412,7 +412,7 @@ private:
|
|||
/**
|
||||
* Track locally submitted transactions to periodically retry initial broadcast.
|
||||
*/
|
||||
std::set<uint256> m_unbroadcast_txids GUARDED_BY(cs);
|
||||
std::set<Txid> m_unbroadcast_txids GUARDED_BY(cs);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -434,7 +434,7 @@ private:
|
|||
|
||||
public:
|
||||
indirectmap<COutPoint, const CTransaction*> mapNextTx GUARDED_BY(cs);
|
||||
std::map<uint256, CAmount> mapDeltas GUARDED_BY(cs);
|
||||
std::map<Txid, CAmount> mapDeltas GUARDED_BY(cs);
|
||||
|
||||
using Options = kernel::MemPoolOptions;
|
||||
|
||||
|
@ -479,9 +479,9 @@ public:
|
|||
bool HasNoInputsOf(const CTransaction& tx) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** Affect CreateNewBlock prioritisation of transactions */
|
||||
void PrioritiseTransaction(const uint256& hash, const CAmount& nFeeDelta);
|
||||
void ApplyDelta(const uint256& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
void ClearPrioritisation(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
void PrioritiseTransaction(const Txid& hash, const CAmount& nFeeDelta);
|
||||
void ApplyDelta(const Txid& hash, CAmount &nFeeDelta) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
void ClearPrioritisation(const Txid& hash) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
struct delta_info {
|
||||
/** Whether this transaction is in the mempool. */
|
||||
|
@ -491,7 +491,7 @@ public:
|
|||
/** 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;
|
||||
const Txid txid;
|
||||
};
|
||||
/** Return a vector of all entries in mapDeltas with their corresponding delta_info. */
|
||||
std::vector<delta_info> GetPrioritisedTransactions() const EXCLUSIVE_LOCKS_REQUIRED(!cs);
|
||||
|
@ -500,7 +500,7 @@ public:
|
|||
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);
|
||||
std::optional<txiter> GetIter(const Txid& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
|
||||
/** Translate a set of hashes into a set of pool iterators to avoid repeated lookups.
|
||||
* Does not require that all of the hashes correspond to actual transactions in the mempool,
|
||||
|
@ -525,7 +525,7 @@ public:
|
|||
* @param[in] vHashesToUpdate The set of txids from the
|
||||
* disconnected block that have been accepted back into the mempool.
|
||||
*/
|
||||
void UpdateTransactionsFromBlock(const std::vector<uint256>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main) LOCKS_EXCLUDED(m_epoch);
|
||||
void UpdateTransactionsFromBlock(const std::vector<Txid>& vHashesToUpdate) EXCLUSIVE_LOCKS_REQUIRED(cs, cs_main) LOCKS_EXCLUDED(m_epoch);
|
||||
|
||||
/**
|
||||
* Try to calculate all in-mempool ancestors of entry.
|
||||
|
@ -614,7 +614,7 @@ public:
|
|||
* When ancestors is non-zero (ie, the transaction itself is in the mempool),
|
||||
* ancestorsize and ancestorfees will also be set to the appropriate values.
|
||||
*/
|
||||
void GetTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) const;
|
||||
void GetTransactionAncestry(const Txid& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) const;
|
||||
|
||||
/**
|
||||
* @returns true if an initial attempt to load the persisted mempool was made, regardless of
|
||||
|
@ -657,8 +657,8 @@ public:
|
|||
|
||||
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)
|
||||
CTransactionRef get(const Txid& hash) const;
|
||||
txiter get_iter_from_wtxid(const Wtxid& wtxid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
return mapTx.project<0>(mapTx.get<index_by_wtxid>().find(wtxid));
|
||||
|
@ -674,26 +674,26 @@ public:
|
|||
size_t DynamicMemoryUsage() const;
|
||||
|
||||
/** Adds a transaction to the unbroadcast set */
|
||||
void AddUnbroadcastTx(const uint256& txid)
|
||||
void AddUnbroadcastTx(const Txid& txid)
|
||||
{
|
||||
LOCK(cs);
|
||||
// Sanity check the transaction is in the mempool & insert into
|
||||
// unbroadcast set.
|
||||
if (exists(Txid::FromUint256(txid))) m_unbroadcast_txids.insert(txid);
|
||||
if (exists(txid)) m_unbroadcast_txids.insert(txid);
|
||||
};
|
||||
|
||||
/** Removes a transaction from the unbroadcast set */
|
||||
void RemoveUnbroadcastTx(const uint256& txid, const bool unchecked = false);
|
||||
void RemoveUnbroadcastTx(const Txid& txid, const bool unchecked = false);
|
||||
|
||||
/** Returns transactions in unbroadcast set */
|
||||
std::set<uint256> GetUnbroadcastTxs() const
|
||||
std::set<Txid> GetUnbroadcastTxs() const
|
||||
{
|
||||
LOCK(cs);
|
||||
return m_unbroadcast_txids;
|
||||
}
|
||||
|
||||
/** Returns whether a txid is in the unbroadcast set */
|
||||
bool IsUnbroadcastTx(const uint256& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
|
||||
bool IsUnbroadcastTx(const Txid& txid) const EXCLUSIVE_LOCKS_REQUIRED(cs)
|
||||
{
|
||||
AssertLockHeld(cs);
|
||||
return m_unbroadcast_txids.count(txid) != 0;
|
||||
|
@ -752,7 +752,7 @@ private:
|
|||
* removeRecursive them.
|
||||
*/
|
||||
void UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendants,
|
||||
const std::set<uint256>& setExclude, std::set<uint256>& descendants_to_remove) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
const std::set<Txid>& setExclude, std::set<Txid>& descendants_to_remove) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
/** Update ancestors of hash to add/remove it as a descendant transaction. */
|
||||
void UpdateAncestorsOf(bool add, txiter hash, setEntries &setAncestors) EXCLUSIVE_LOCKS_REQUIRED(cs);
|
||||
/** Set ancestor state for an entry */
|
||||
|
|
|
@ -301,7 +301,7 @@ void Chainstate::MaybeUpdateMempoolForReorg(
|
|||
|
||||
AssertLockHeld(cs_main);
|
||||
AssertLockHeld(m_mempool->cs);
|
||||
std::vector<uint256> vHashUpdate;
|
||||
std::vector<Txid> vHashUpdate;
|
||||
{
|
||||
// disconnectpool is ordered so that the front is the most recently-confirmed
|
||||
// transaction (the last tx of the block at the tip) in the disconnected chain.
|
||||
|
|
Loading…
Add table
Reference in a new issue