From 9fce0629b437441cb09c14055ee810b8ee6b7978 Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Sat, 18 Jun 2016 19:38:28 +0200 Subject: [c++11] Use std::unique_ptr for block creation. CreateNewBlock returns a pointer for which the caller takes ownership. Use std::unique_ptr to make this explicit and simplify handling of these objects in getblocktemplate. --- src/test/test_bitcoin.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/test/test_bitcoin.cpp') diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index c68320ba8..98b02a1f6 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -22,6 +22,8 @@ #include "test/testutil.h" +#include + #include #include #include @@ -98,7 +100,7 @@ CBlock TestChain100Setup::CreateAndProcessBlock(const std::vector& txns, const CScript& scriptPubKey) { const CChainParams& chainparams = Params(); - CBlockTemplate *pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey); + std::unique_ptr pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey); CBlock& block = pblocktemplate->block; // Replace mempool-selected txns with just coinbase plus passed-in txns: @@ -115,7 +117,6 @@ TestChain100Setup::CreateAndProcessBlock(const std::vector& ProcessNewBlock(state, chainparams, NULL, &block, true, NULL); CBlock result = block; - delete pblocktemplate; return result; } -- cgit v1.2.3