mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Switch pblock in ProcessNewBlock to a shared_ptr
This (finally) fixes a performance regression in
b3b3c2a562
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user