Possible fix for miner crashing on OnDemand Blocks
This commit is contained in:
@@ -214,15 +214,13 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
boost::optional<CTransaction> cheatSpend;
|
||||
uint256 cbHash;
|
||||
|
||||
SaplingMerkleTree sapling_tree; uint64_t commission;
|
||||
int nHeight = 0;
|
||||
const Consensus::Params &consensusParams = chainparams.GetConsensus();
|
||||
|
||||
CBlockIndex* pindexPrev = chainActive.LastTip();;
|
||||
CBlockIndex* pindexPrev = 0;
|
||||
{
|
||||
{ // contain lock to block generation and not staking loops.
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
nHeight = pindexPrev->GetHeight() + 1;
|
||||
ENTER_CRITICAL_SECTION(cs_main);
|
||||
ENTER_CRITICAL_SECTION(mempool.cs);
|
||||
pindexPrev = chainActive.LastTip();
|
||||
const int nHeight = pindexPrev->GetHeight() + 1;
|
||||
const Consensus::Params &consensusParams = chainparams.GetConsensus();
|
||||
uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams);
|
||||
bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING);
|
||||
|
||||
@@ -242,8 +240,9 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
pblock->nTime = GetAdjustedTime();
|
||||
|
||||
CCoinsViewCache view(pcoinsTip);
|
||||
uint32_t expired;
|
||||
uint32_t expired; uint64_t commission;
|
||||
|
||||
SaplingMerkleTree sapling_tree; uint64_t commission;
|
||||
assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree));
|
||||
|
||||
// Priority order to process transactions
|
||||
@@ -473,8 +472,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
//pblock->nTime = blocktime + 1;
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||
|
||||
} // contain lock to block generation only!
|
||||
|
||||
int32_t stakeHeight = chainActive.Height() + 1;
|
||||
|
||||
//LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);
|
||||
@@ -500,7 +497,11 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
blocktime = GetAdjustedTime();
|
||||
//if ( blocktime > pindexPrev->GetMedianTimePast()+60 )
|
||||
// blocktime = pindexPrev->GetMedianTimePast() + 60;
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig);
|
||||
ENTER_CRITICAL_SECTION(cs_main);
|
||||
ENTER_CRITICAL_SECTION(mempool.cs);
|
||||
}
|
||||
|
||||
if ( siglen > 0 )
|
||||
@@ -654,6 +655,8 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
//fprintf(stderr,"valid\n");
|
||||
}
|
||||
}
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||
//fprintf(stderr,"done new block\n");
|
||||
return pblocktemplate.release();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user