Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | int nHeight = 0; | ||||
nHeight = nHeightStart; | nHeight = nHeightStart; | ||||
nHeightEnd = nHeightStart + nGenerate; | nHeightEnd = nHeightStart + nGenerate; | ||||
} | } | ||||
unsigned int nExtraNonce = 0; | unsigned int nExtraNonce = 0; | ||||
UniValue blockHashes(UniValue::VARR); | UniValue blockHashes(UniValue::VARR); | ||||
while (nHeight < nHeightEnd) { | while (nHeight < nHeightEnd) { | ||||
std::unique_ptr<CBlockTemplate> pblocktemplate( | std::unique_ptr<CBlockTemplate> pblocktemplate( | ||||
BlockAssembler(config).CreateNewBlock( | BlockAssembler(config, g_mempool) | ||||
coinbaseScript->reserveScript)); | .CreateNewBlock(coinbaseScript->reserveScript)); | ||||
if (!pblocktemplate.get()) { | if (!pblocktemplate.get()) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); | throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); | ||||
} | } | ||||
CBlock *pblock = &pblocktemplate->block; | CBlock *pblock = &pblocktemplate->block; | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 437 Lines • ▼ Show 20 Lines | if (pindexPrev != chainActive.Tip() || | ||||
// Store the pindexBest used before CreateNewBlock, to avoid races | // Store the pindexBest used before CreateNewBlock, to avoid races | ||||
nTransactionsUpdatedLast = g_mempool.GetTransactionsUpdated(); | nTransactionsUpdatedLast = g_mempool.GetTransactionsUpdated(); | ||||
CBlockIndex *pindexPrevNew = chainActive.Tip(); | CBlockIndex *pindexPrevNew = chainActive.Tip(); | ||||
nStart = GetTime(); | nStart = GetTime(); | ||||
// Create new block | // Create new block | ||||
CScript scriptDummy = CScript() << OP_TRUE; | CScript scriptDummy = CScript() << OP_TRUE; | ||||
pblocktemplate = BlockAssembler(config).CreateNewBlock(scriptDummy); | pblocktemplate = | ||||
BlockAssembler(config, g_mempool).CreateNewBlock(scriptDummy); | |||||
if (!pblocktemplate) { | if (!pblocktemplate) { | ||||
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); | throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); | ||||
} | } | ||||
// Need to update only after we know CreateNewBlock succeeded | // Need to update only after we know CreateNewBlock succeeded | ||||
pindexPrev = pindexPrevNew; | pindexPrev = pindexPrevNew; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 238 Lines • Show Last 20 Lines |