Skip to content

Commit fa8a888

Browse files
author
MarcoFalke
committed
bench: Remove duplicate constants
1 parent 000098f commit fa8a888

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/bench/block_assemble.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <consensus/validation.h>
77
#include <crypto/sha256.h>
88
#include <test/util/mining.h>
9+
#include <test/util/script.h>
910
#include <test/util/setup_common.h>
1011
#include <test/util/wallet.h>
1112
#include <txmempool.h>
@@ -18,23 +19,17 @@ static void AssembleBlock(benchmark::Bench& bench)
1819
{
1920
const auto test_setup = MakeNoLogFileContext<const TestingSetup>();
2021

21-
const std::vector<unsigned char> op_true{OP_TRUE};
2222
CScriptWitness witness;
23-
witness.stack.push_back(op_true);
24-
25-
uint256 witness_program;
26-
CSHA256().Write(&op_true[0], op_true.size()).Finalize(witness_program.begin());
27-
28-
const CScript SCRIPT_PUB{CScript(OP_0) << std::vector<unsigned char>{witness_program.begin(), witness_program.end()}};
23+
witness.stack.push_back(WITNESS_STACK_ELEM_OP_TRUE);
2924

3025
// Collect some loose transactions that spend the coinbases of our mined blocks
3126
constexpr size_t NUM_BLOCKS{200};
3227
std::array<CTransactionRef, NUM_BLOCKS - COINBASE_MATURITY + 1> txs;
3328
for (size_t b{0}; b < NUM_BLOCKS; ++b) {
3429
CMutableTransaction tx;
35-
tx.vin.push_back(MineBlock(test_setup->m_node, SCRIPT_PUB));
30+
tx.vin.push_back(MineBlock(test_setup->m_node, P2WSH_OP_TRUE));
3631
tx.vin.back().scriptWitness = witness;
37-
tx.vout.emplace_back(1337, SCRIPT_PUB);
32+
tx.vout.emplace_back(1337, P2WSH_OP_TRUE);
3833
if (NUM_BLOCKS - b >= COINBASE_MATURITY)
3934
txs.at(b) = MakeTransactionRef(tx);
4035
}
@@ -48,7 +43,7 @@ static void AssembleBlock(benchmark::Bench& bench)
4843
}
4944

5045
bench.run([&] {
51-
PrepareBlock(test_setup->m_node, SCRIPT_PUB);
46+
PrepareBlock(test_setup->m_node, P2WSH_OP_TRUE);
5247
});
5348
}
5449

0 commit comments

Comments
 (0)