aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/mining.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-10-18 21:11:22 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-10-18 21:16:08 +0200
commit744d2652dda0251bad7c1d8e3bbb468c2fe27510 (patch)
treee5ec5ff5dd0238954af403425b94a4e084369244 /src/rpc/mining.cpp
parente10af96cf450494fdb893b71540e709ed311b871 (diff)
parent9fce0629b437441cb09c14055ee810b8ee6b7978 (diff)
Merge #8223: [c++11] Use std::unique_ptr for block creation.
9fce062 [c++11] Use std::unique_ptr for block creation. (Daniel Kraft)
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r--src/rpc/mining.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index fa64ce8fad..cd3bb5c924 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -22,6 +22,7 @@
#include "utilstrencodings.h"
#include "validationinterface.h"
+#include <memory>
#include <stdint.h>
#include <boost/assign/list_of.hpp>
@@ -515,12 +516,12 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
// Update block
static CBlockIndex* pindexPrev;
static int64_t nStart;
- static CBlockTemplate* pblocktemplate;
+ static std::unique_ptr<CBlockTemplate> pblocktemplate;
if (pindexPrev != chainActive.Tip() ||
(mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 5))
{
// Clear pindexPrev so future calls make a new block, despite any failures from here on
- pindexPrev = NULL;
+ pindexPrev = nullptr;
// Store the pindexBest used before CreateNewBlock, to avoid races
nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
@@ -528,11 +529,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
nStart = GetTime();
// Create new block
- if(pblocktemplate)
- {
- delete pblocktemplate;
- pblocktemplate = NULL;
- }
CScript scriptDummy = CScript() << OP_TRUE;
pblocktemplate = BlockAssembler(Params()).CreateNewBlock(scriptDummy);
if (!pblocktemplate)