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