mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-19 13:27:35 +02:00
Merge 489b587669 into merged_master (Bitcoin PR bitcoin/bitcoin#25215)
This commit is contained in:
commit
fe8d041f9f
9 changed files with 29 additions and 26 deletions
|
|
@ -121,7 +121,7 @@ static void MempoolEviction(benchmark::Bench& bench)
|
|||
tx7.vout[1].scriptPubKey = CScript() << OP_7 << OP_EQUAL;
|
||||
tx7.vout[1].nValue = 10 * COIN;
|
||||
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(testing_setup->m_node.mempool);
|
||||
LOCK2(cs_main, pool.cs);
|
||||
// Create transaction references outside the "hot loop"
|
||||
const CTransactionRef tx1_r{MakeTransactionRef(tx1)};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <bench/bench.h>
|
||||
#include <chainparamsbase.h>
|
||||
#include <rpc/mempool.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <txmempool.h>
|
||||
|
||||
#include <univalue.h>
|
||||
|
|
@ -18,7 +20,8 @@ static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& poo
|
|||
|
||||
static void RpcMempool(benchmark::Bench& bench)
|
||||
{
|
||||
CTxMemPool pool;
|
||||
const auto testing_setup = MakeNoLogFileContext<const ChainTestingSetup>(CBaseChainParams::MAIN);
|
||||
CTxMemPool& pool = *Assert(testing_setup->m_node.mempool);
|
||||
LOCK2(cs_main, pool.cs);
|
||||
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
|
|
|
|||
|
|
@ -4699,7 +4699,7 @@ void PeerManagerImpl::MaybeSendFeefilter(CNode& pto, Peer& peer, std::chrono::mi
|
|||
namespace {
|
||||
class CompareInvMempoolOrder
|
||||
{
|
||||
CTxMemPool *mp;
|
||||
CTxMemPool* mp;
|
||||
bool m_wtxid_relay;
|
||||
public:
|
||||
explicit CompareInvMempoolOrder(CTxMemPool *_mempool, bool use_wtxid)
|
||||
|
|
|
|||
10
src/rest.cpp
10
src/rest.cpp
|
|
@ -812,10 +812,10 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
|
|||
if (!maybe_chainman) return false;
|
||||
ChainstateManager& chainman = *maybe_chainman;
|
||||
{
|
||||
auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool& mempool) {
|
||||
auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool* mempool) {
|
||||
for (const COutPoint& vOutPoint : vOutPoints) {
|
||||
Coin coin;
|
||||
bool hit = !mempool.isSpent(vOutPoint) && view.GetCoin(vOutPoint, coin);
|
||||
bool hit = (!mempool || !mempool->isSpent(vOutPoint)) && view.GetCoin(vOutPoint, coin);
|
||||
hits.push_back(hit);
|
||||
if (hit) outs.emplace_back(std::move(coin));
|
||||
}
|
||||
|
|
@ -828,10 +828,10 @@ static bool rest_getutxos(const std::any& context, HTTPRequest* req, const std::
|
|||
LOCK2(cs_main, mempool->cs);
|
||||
CCoinsViewCache& viewChain = chainman.ActiveChainstate().CoinsTip();
|
||||
CCoinsViewMemPool viewMempool(&viewChain, *mempool);
|
||||
process_utxos(viewMempool, *mempool);
|
||||
process_utxos(viewMempool, mempool);
|
||||
} else {
|
||||
LOCK(cs_main); // no need to lock mempool!
|
||||
process_utxos(chainman.ActiveChainstate().CoinsTip(), CTxMemPool());
|
||||
LOCK(cs_main);
|
||||
process_utxos(chainman.ActiveChainstate().CoinsTip(), nullptr);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < hits.size(); ++i) {
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ constexpr long SHARED_TX_OFFSET{3};
|
|||
|
||||
BOOST_AUTO_TEST_CASE(SimpleRoundTripTest)
|
||||
{
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
TestMemPoolEntryHelper entry;
|
||||
CBlock block(BuildBlockTestCase());
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ public:
|
|||
|
||||
BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
|
||||
{
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
TestMemPoolEntryHelper entry;
|
||||
CBlock block(BuildBlockTestCase());
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
|
||||
{
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
TestMemPoolEntryHelper entry;
|
||||
CBlock block(BuildBlockTestCase());
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest)
|
||||
{
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
CMutableTransaction coinbase;
|
||||
coinbase.vin.resize(1);
|
||||
coinbase.vin[0].scriptSig.resize(10);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
|
|||
}
|
||||
|
||||
|
||||
CTxMemPool testPool;
|
||||
CTxMemPool& testPool = *Assert(m_node.mempool);
|
||||
LOCK2(cs_main, testPool.cs);
|
||||
|
||||
// Nothing in pool, remove should do nothing:
|
||||
|
|
@ -109,12 +109,12 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest)
|
|||
BOOST_CHECK_EQUAL(testPool.size(), 0U);
|
||||
}
|
||||
|
||||
template<typename name>
|
||||
static void CheckSort(CTxMemPool &pool, std::vector<std::string> &sortedOrder) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
|
||||
template <typename name>
|
||||
static void CheckSort(CTxMemPool& pool, std::vector<std::string>& sortedOrder) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(pool.size(), sortedOrder.size());
|
||||
typename CTxMemPool::indexed_transaction_set::index<name>::type::iterator it = pool.mapTx.get<name>().begin();
|
||||
int count=0;
|
||||
int count = 0;
|
||||
for (; it != pool.mapTx.get<name>().end(); ++it, ++count) {
|
||||
BOOST_CHECK_EQUAL(it->GetTx().GetHash().ToString(), sortedOrder[count]);
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ static void CheckSort(CTxMemPool &pool, std::vector<std::string> &sortedOrder) E
|
|||
|
||||
BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
|
||||
{
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
LOCK2(cs_main, pool.cs);
|
||||
TestMemPoolEntryHelper entry;
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(MempoolIndexingTest)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
|
||||
{
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
LOCK2(cs_main, pool.cs);
|
||||
TestMemPoolEntryHelper entry;
|
||||
|
||||
|
|
@ -423,7 +423,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestorIndexingTest)
|
|||
|
||||
BOOST_AUTO_TEST_CASE(MempoolSizeLimitTest)
|
||||
{
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
LOCK2(cs_main, pool.cs);
|
||||
TestMemPoolEntryHelper entry;
|
||||
|
||||
|
|
@ -594,7 +594,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
|
|||
{
|
||||
size_t ancestors, descendants;
|
||||
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
LOCK2(cs_main, pool.cs);
|
||||
TestMemPoolEntryHelper entry;
|
||||
|
||||
|
|
@ -753,7 +753,7 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTestsDiamond)
|
|||
{
|
||||
size_t ancestors, descendants;
|
||||
|
||||
CTxMemPool pool;
|
||||
CTxMemPool& pool = *Assert(m_node.mempool);
|
||||
LOCK2(::cs_main, pool.cs);
|
||||
TestMemPoolEntryHelper entry;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@
|
|||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(policyestimator_tests, BasicTestingSetup)
|
||||
BOOST_FIXTURE_TEST_SUITE(policyestimator_tests, ChainTestingSetup)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(BlockPolicyEstimates)
|
||||
{
|
||||
CBlockPolicyEstimator feeEst;
|
||||
CTxMemPool mpool(&feeEst);
|
||||
CBlockPolicyEstimator& feeEst = *Assert(m_node.fee_estimator);
|
||||
CTxMemPool& mpool = *Assert(m_node.mempool);
|
||||
LOCK2(cs_main, mpool.cs);
|
||||
TestMemPoolEntryHelper entry;
|
||||
CAmount basefee(2000);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ BOOST_AUTO_TEST_CASE(validation_chainstate_resize_caches)
|
|||
ChainstateManager manager{chainman_opts};
|
||||
|
||||
WITH_LOCK(::cs_main, manager.m_blockman.m_block_tree_db = std::make_unique<CBlockTreeDB>(1 << 20, true));
|
||||
CTxMemPool mempool;
|
||||
CTxMemPool& mempool = *Assert(m_node.mempool);
|
||||
|
||||
//! Create and add a Coin with DynamicMemoryUsage of 80 bytes to the given view.
|
||||
auto add_coin = [](CCoinsViewCache& coins_view) -> COutPoint {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_flush_tests, ChainTestingSetup)
|
|||
//!
|
||||
BOOST_AUTO_TEST_CASE(getcoinscachesizestate)
|
||||
{
|
||||
CTxMemPool mempool;
|
||||
CTxMemPool& mempool = *Assert(m_node.mempool);
|
||||
BlockManager blockman{};
|
||||
CChainState chainstate{&mempool, blockman, *Assert(m_node.chainman)};
|
||||
chainstate.InitCoinsDB(/*cache_size_bytes=*/1 << 10, /*in_memory=*/true, /*should_wipe=*/false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue