@@ -204,27 +204,24 @@ TestChain100Setup::TestChain100Setup()
204
204
205
205
// Generate a 100-block chain:
206
206
coinbaseKey.MakeNewKey (true );
207
- CScript scriptPubKey = CScript () << ToByteVector (coinbaseKey.GetPubKey ()) << OP_CHECKSIG;
208
- for (int i = 0 ; i < COINBASE_MATURITY; i++)
209
- {
207
+ CScript scriptPubKey = CScript () << ToByteVector (coinbaseKey.GetPubKey ()) << OP_CHECKSIG;
208
+ for (int i = 0 ; i < COINBASE_MATURITY; i++) {
210
209
std::vector<CMutableTransaction> noTxns;
211
210
CBlock b = CreateAndProcessBlock (noTxns, scriptPubKey);
212
211
m_coinbase_txns.push_back (b.vtx [0 ]);
213
212
}
214
213
}
215
214
216
- // Create a new block with just given transactions, coinbase paying to
217
- // scriptPubKey, and try to add it to the current chain.
218
215
CBlock TestChain100Setup::CreateAndProcessBlock (const std::vector<CMutableTransaction>& txns, const CScript& scriptPubKey)
219
216
{
220
217
const CChainParams& chainparams = Params ();
221
- std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler (*m_node.mempool , chainparams).CreateNewBlock (scriptPubKey);
222
- CBlock& block = pblocktemplate->block ;
218
+ CBlock block = BlockAssembler (*m_node.mempool , chainparams).CreateNewBlock (scriptPubKey)->block ;
223
219
224
220
// Replace mempool-selected txns with just coinbase plus passed-in txns:
225
221
block.vtx .resize (1 );
226
- for (const CMutableTransaction& tx : txns)
222
+ for (const CMutableTransaction& tx : txns) {
227
223
block.vtx .push_back (MakeTransactionRef (tx));
224
+ }
228
225
// IncrementExtraNonce creates a valid coinbase and merkleRoot
229
226
{
230
227
LOCK (cs_main);
@@ -237,17 +234,16 @@ CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector<CMutableTransa
237
234
std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(block);
238
235
Assert (m_node.chainman )->ProcessNewBlock (chainparams, shared_pblock, true , nullptr );
239
236
240
- CBlock result = block;
241
- return result;
237
+ return block;
242
238
}
243
239
244
240
TestChain100Setup::~TestChain100Setup ()
245
241
{
246
242
gArgs .ForceSetArg (" -segwitheight" , " 0" );
247
243
}
248
244
249
-
250
- CTxMemPoolEntry TestMemPoolEntryHelper::FromTx ( const CMutableTransaction &tx) {
245
+ CTxMemPoolEntry TestMemPoolEntryHelper::FromTx ( const CMutableTransaction& tx)
246
+ {
251
247
return FromTx (MakeTransactionRef (tx));
252
248
}
253
249
0 commit comments