mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-27 19:47:30 -03:00
f47dda2c58
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: * 2020:fa0074e2d8
* 2019:aaaaad6ac9
50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
// Copyright (c) 2011-2021 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <bench/bench.h>
|
|
#include <consensus/validation.h>
|
|
#include <crypto/sha256.h>
|
|
#include <test/util/mining.h>
|
|
#include <test/util/script.h>
|
|
#include <test/util/setup_common.h>
|
|
#include <test/util/wallet.h>
|
|
#include <txmempool.h>
|
|
#include <validation.h>
|
|
|
|
|
|
#include <vector>
|
|
|
|
static void AssembleBlock(benchmark::Bench& bench)
|
|
{
|
|
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
|
|
|
CScriptWitness witness;
|
|
witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE);
|
|
|
|
// Collect some loose transactions that spend the coinbases of our mined blocks
|
|
constexpr size_t NUM_BLOCKS{200};
|
|
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
|
|
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
|
|
CMutableTransaction tx;
|
|
tx.vin.push_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE));
|
|
tx.vin.back().scriptWitness = witness;
|
|
tx.vout.emplace_back(1337, P2WSH_OP_TRUE);
|
|
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
|
|
txs.at(b) = MakeTransactionRef(tx);
|
|
}
|
|
{
|
|
LOCK(::cs_main);
|
|
|
|
for (const auto& txr : txs) {
|
|
const MempoolAcceptResult res = test_setup->m_node.chainman->ProcessTransaction(txr);
|
|
assert(res.m_result_type == MempoolAcceptResult::ResultType::VALID);
|
|
}
|
|
}
|
|
|
|
bench.run([&] {
|
|
PrepareBlock(test_setup->m_node, P2WSH_OP_TRUE);
|
|
});
|
|
}
|
|
|
|
BENCHMARK(AssembleBlock);
|