Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
block_assemble.cpp
Go to the documentation of this file.
1// Copyright (c) 2011-2017 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#include <bench/bench.h>
6#include <config.h>
8#include <script/standard.h>
9#include <test/util/mining.h>
10#include <test/util/setup_common.h>
11#include <test/util/wallet.h>
12#include <txmempool.h>
13#include <validation.h>
14
15#include <vector>
16
19 const Config &config = test_setup->m_node.chainman->GetConfig();
20
22 const CScript SCRIPT_PUB =
24 << OP_EQUAL;
25
26 const CScript scriptSig = CScript() << std::vector<uint8_t>(100, 0xff)
28
29 // Collect some loose transactions that spend the coinbases of our mined
30 // blocks
31 constexpr size_t NUM_BLOCKS{200};
33 for (size_t b = 0; b < NUM_BLOCKS; ++b) {
35 tx.vin.push_back(MineBlock(config, test_setup->m_node, SCRIPT_PUB));
36 tx.vin.back().scriptSig = scriptSig;
37 tx.vout.emplace_back(1337 * SATOSHI, SCRIPT_PUB);
39 txs.at(b) = MakeTransactionRef(tx);
40 }
41 }
42
43 {
45
46 for (const auto &txr : txs) {
48 test_setup->m_node.chainman->ProcessTransaction(txr);
50 }
51 }
52
53 bench.run([&] { PrepareBlock(config, test_setup->m_node, SCRIPT_PUB); });
54}
55
static constexpr Amount SATOSHI
Definition amount.h:143
#define BENCHMARK(n)
Definition bench.h:65
static void AssembleBlock(benchmark::Bench &bench)
A mutable version of CTransaction.
std::vector< CTxOut > vout
std::vector< CTxIn > vin
Serialized script, used inside transaction inputs and outputs.
Definition script.h:424
A reference to a CScript: the Hash160 of its serialization (see script.h)
Definition standard.h:24
Main entry point to nanobench's benchmarking facility.
Definition nanobench.h:616
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule).
Definition consensus.h:32
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition cs_main.cpp:7
static CTransactionRef MakeTransactionRef()
std::shared_ptr< const CTransaction > CTransactionRef
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
@ OP_EQUAL
Definition script.h:119
@ OP_HASH160
Definition script.h:160
@ OP_TRUE
Definition script.h:57
@ OP_DROP
Definition script.h:97
std::vector< uint8_t > ToByteVector(const T &in)
Definition script.h:42
Validation result for a transaction evaluated by MemPoolAccept (single or package).
Definition validation.h:207
@ VALID
Fully validated, valid.
#define LOCK(cs)
Definition sync.h:306
assert(!tx.IsCoinBase())