Fix lockups with ram staker!
This commit is contained in:
@@ -200,12 +200,15 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
boost::optional<CTransaction> cheatSpend;
|
||||
uint256 cbHash;
|
||||
|
||||
CBlockIndex* pindexPrev = 0;
|
||||
{
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
pindexPrev = chainActive.LastTip();
|
||||
const int nHeight = pindexPrev->GetHeight() + 1;
|
||||
SaplingMerkleTree sapling_tree; uint64_t commission;
|
||||
int nHeight = 0;
|
||||
const Consensus::Params &consensusParams = chainparams.GetConsensus();
|
||||
|
||||
CBlockIndex* pindexPrev = chainActive.LastTip();;
|
||||
{
|
||||
{ // contain lock to block generation and not staking loops.
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
nHeight = pindexPrev->GetHeight() + 1;
|
||||
uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams);
|
||||
bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING);
|
||||
|
||||
@@ -225,9 +228,8 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
pblock->nTime = GetAdjustedTime();
|
||||
|
||||
CCoinsViewCache view(pcoinsTip);
|
||||
uint32_t expired; uint64_t commission;
|
||||
uint32_t expired;
|
||||
|
||||
SaplingMerkleTree sapling_tree;
|
||||
assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree));
|
||||
|
||||
// Priority order to process transactions
|
||||
@@ -314,19 +316,17 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
|
||||
int nConf = nHeight - coins->nHeight;
|
||||
|
||||
if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 && fToCryptoAddress )
|
||||
// This is to test is a tx is a notarisation and assign it max priotity.
|
||||
if ( fToCryptoAddress && NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 )
|
||||
{
|
||||
uint256 hash; CTransaction tx1; CTxDestination address;
|
||||
if (GetTransaction(txin.prevout.hash,tx1,hash,false))
|
||||
if ( GetTransaction(txin.prevout.hash,tx1,hash,false) && (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) )
|
||||
{
|
||||
if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) {
|
||||
for (int i = 0; i < NUM_NOTARIES; i++) {
|
||||
for (int i = 0; i < NUM_NOTARIES; i++)
|
||||
if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 )
|
||||
numNotaryVins++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dPriority += (double)nValueIn * nConf;
|
||||
}
|
||||
if ( NUM_NOTARIES != 0 && numNotaryVins >= NUM_NOTARIES / 5 )
|
||||
@@ -481,6 +481,8 @@ 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);
|
||||
@@ -523,7 +525,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
//printf("staking PoS ht.%d t%u lag.%u\n",(int32_t)chainActive.LastTip()->GetHeight()+1,blocktime,(uint32_t)(GetAdjustedTime() - (blocktime-13)));
|
||||
} else return(0); //fprintf(stderr,"no utxos eligible for staking\n");
|
||||
}
|
||||
|
||||
// Create coinbase tx
|
||||
CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight);
|
||||
txNew.vin.resize(1);
|
||||
|
||||
Reference in New Issue
Block a user