bench: Remove duplicate constants
This commit is contained in:
1 file changed
+5
-10
@@ -6,6 +6,7 @@
|
|||||||
#include <consensus/validation.h>
|
#include <consensus/validation.h>
|
||||||
#include <crypto/sha256.h>
|
#include <crypto/sha256.h>
|
||||||
#include <test/util/mining.h>
|
#include <test/util/mining.h>
|
||||||
|
#include <test/util/script.h>
|
||||||
#include <test/util/setup_common.h>
|
#include <test/util/setup_common.h>
|
||||||
#include <test/util/wallet.h>
|
#include <test/util/wallet.h>
|
||||||
#include <txmempool.h>
|
#include <txmempool.h>
|
||||||
@@ -18,23 +19,17 @@ static void AssembleBlock(benchmark::Bench& bench)
|
|||||||
{
|
{
|
||||||
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
|
||||||
|
|
||||||
const std::vector<unsigned char> op_true{OP_TRUE};
|
|
||||||
CScriptWitness witness;
|
CScriptWitness witness;
|
||||||
witness.stack.push_back(op_true);
|
witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE);
|
||||||
|
|
||||||
uint256 witness_program;
|
|
||||||
CSHA256().Write(&op_true[0], op_true.size()).Finalize(witness_program.begin());
|
|
||||||
|
|
||||||
const CScript SCRIPT_PUB{CScript(OP_0) << std::vector<unsigned char>{witness_program.begin(), witness_program.end()}};
|
|
||||||
|
|
||||||
// Collect some loose transactions that spend the coinbases of our mined blocks
|
// Collect some loose transactions that spend the coinbases of our mined blocks
|
||||||
constexpr size_t NUM_BLOCKS{200};
|
constexpr size_t NUM_BLOCKS{200};
|
||||||
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
|
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
|
||||||
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
|
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
|
||||||
CMutableTransaction tx;
|
CMutableTransaction tx;
|
||||||
tx.vin.push_back(MineBlock(test_setup->m_node, SCRIPT_PUB));
|
tx.vin.push_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE));
|
||||||
tx.vin.back().scriptWitness = witness;
|
tx.vin.back().scriptWitness = witness;
|
||||||
tx.vout.emplace_back(1337, SCRIPT_PUB);
|
tx.vout.emplace_back(1337, P2WSH_OP_TRUE);
|
||||||
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
|
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
|
||||||
txs.at(b) = MakeTransactionRef(tx);
|
txs.at(b) = MakeTransactionRef(tx);
|
||||||
}
|
}
|
||||||
@@ -48,7 +43,7 @@ static void AssembleBlock(benchmark::Bench& bench)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bench.run([&] {
|
bench.run([&] {
|
||||||
PrepareBlock(test_setup->m_node, SCRIPT_PUB);
|
PrepareBlock(test_setup->m_node, P2WSH_OP_TRUE);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user