aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/mining.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2016-12-04 00:17:30 -0800
committerMatt Corallo <git@bluematt.me>2016-12-04 00:17:30 -0800
commit2d6e5619afa2d43a37a0a38daf33f58965ddfa80 (patch)
tree9bdc85dfd1048bc7d7f2d535d9f63b3b373ef4d9 /src/rpc/mining.cpp
parent2736c44c8edea5ce6a502a04269926fecda27301 (diff)
downloadbitcoin-2d6e5619afa2d43a37a0a38daf33f58965ddfa80.tar.xz
Switch pblock in ProcessNewBlock to a shared_ptr
This (finally) fixes a performance regression in b3b3c2a5623d5c942d2b3565cc2d833c65105555
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r--src/rpc/mining.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 61408b3b60..cb22dec342 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -131,7 +131,8 @@ UniValue generateBlocks(boost::shared_ptr<CReserveScript> coinbaseScript, int nG
if (pblock->nNonce == nInnerLoopCount) {
continue;
}
- if (!ProcessNewBlock(Params(), pblock, true, NULL, NULL))
+ std::shared_ptr<const CBlock> shared_pblock = std::make_shared<const CBlock>(*pblock);
+ if (!ProcessNewBlock(Params(), shared_pblock, true, NULL, NULL))
throw JSONRPCError(RPC_INTERNAL_ERROR, "ProcessNewBlock, block not accepted");
++nHeight;
blockHashes.push_back(pblock->GetHash().GetHex());
@@ -728,7 +729,8 @@ UniValue submitblock(const JSONRPCRequest& request)
+ HelpExampleRpc("submitblock", "\"mydata\"")
);
- CBlock block;
+ std::shared_ptr<CBlock> blockptr = std::make_shared<CBlock>();
+ CBlock& block = *blockptr;
if (!DecodeHexBlk(block, request.params[0].get_str()))
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed");
@@ -758,7 +760,7 @@ UniValue submitblock(const JSONRPCRequest& request)
submitblock_StateCatcher sc(block.GetHash());
RegisterValidationInterface(&sc);
- bool fAccepted = ProcessNewBlock(Params(), &block, true, NULL, NULL);
+ bool fAccepted = ProcessNewBlock(Params(), blockptr, true, NULL, NULL);
UnregisterValidationInterface(&sc);
if (fBlockPresent)
{