Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/mining.cpp
Show First 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | int nHeight = 0; | ||||
nHeight = ::ChainActive().Height(); | nHeight = ::ChainActive().Height(); | ||||
nHeightEnd = nHeight + nGenerate; | nHeightEnd = nHeight + nGenerate; | ||||
} | } | ||||
unsigned int nExtraNonce = 0; | unsigned int nExtraNonce = 0; | ||||
UniValue blockHashes(UniValue::VARR); | UniValue blockHashes(UniValue::VARR); | ||||
while (nHeight < nHeightEnd && !ShutdownRequested()) { | while (nHeight < nHeightEnd && !ShutdownRequested()) { | ||||
std::unique_ptr<CBlockTemplate> pblocktemplate( | std::unique_ptr<CBlockTemplate> pblocktemplate( | ||||
BlockAssembler(config, mempool).CreateNewBlock(coinbase_script)); | BlockAssembler(config, mempool) | ||||
.CreateNewBlock(::ChainstateActive(), coinbase_script)); | |||||
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; | ||||
BlockHash block_hash; | BlockHash block_hash; | ||||
▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
CBlock block; | CBlock block; | ||||
{ | { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CTxMemPool empty_mempool; | CTxMemPool empty_mempool; | ||||
std::unique_ptr<CBlockTemplate> blocktemplate( | std::unique_ptr<CBlockTemplate> blocktemplate( | ||||
BlockAssembler(config, empty_mempool) | BlockAssembler(config, empty_mempool) | ||||
.CreateNewBlock(coinbase_script)); | .CreateNewBlock(::ChainstateActive(), coinbase_script)); | ||||
if (!blocktemplate) { | if (!blocktemplate) { | ||||
throw JSONRPCError(RPC_INTERNAL_ERROR, | throw JSONRPCError(RPC_INTERNAL_ERROR, | ||||
"Couldn't create new block"); | "Couldn't create new block"); | ||||
} | } | ||||
block = blocktemplate->block; | block = blocktemplate->block; | ||||
} | } | ||||
CHECK_NONFATAL(block.vtx.size() == 1); | CHECK_NONFATAL(block.vtx.size() == 1); | ||||
▲ Show 20 Lines • Show All 468 Lines • ▼ Show 20 Lines | return RPCHelpMan{ | ||||
// races | // races | ||||
nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); | nTransactionsUpdatedLast = 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 = | pblocktemplate = | ||||
BlockAssembler(config, mempool).CreateNewBlock(scriptDummy); | BlockAssembler(config, mempool) | ||||
.CreateNewBlock(::ChainstateActive(), 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 283 Lines • Show Last 20 Lines |