Merge pull request #1106 from blackjok3rtt/FSM

fir mining properly.
This commit is contained in:
jl777
2018-12-17 01:58:00 -11:00
committed by GitHub
7 changed files with 162 additions and 159 deletions

View File

@@ -4710,7 +4710,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
CValidationState state; CValidationState state;
CTransaction Tx; CTransaction Tx;
const CTransaction &tx = (CTransaction)block.vtx[i]; const CTransaction &tx = (CTransaction)block.vtx[i];
if (tx.IsCoinBase() || (!tx.vjoinsplit.empty() && !tx.vShieldedSpend.empty()) || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0))) if (tx.IsCoinBase() || !tx.vjoinsplit.empty() || !tx.vShieldedSpend.empty() || ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED && komodo_isPoS((CBlock *)&block) != 0)))
continue; continue;
Tx = tx; Tx = tx;
if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync if ( myAddtomempool(Tx, &state, true) == false ) // happens with out of order tx in block on resync

View File

@@ -1441,7 +1441,7 @@ void static BitcoinMiner()
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
// notaries always default to staking // notaries always default to staking
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0); CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", -1) == 0);
#else #else
CBlockTemplate *ptr = CreateNewBlockWithKey(); CBlockTemplate *ptr = CreateNewBlockWithKey();
#endif #endif
@@ -1831,7 +1831,7 @@ void static BitcoinMiner()
} }
//fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate); //fprintf(stderr,"nThreads.%d fGenerate.%d\n",(int32_t)nThreads,fGenerate);
if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 ) if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 && fGenerate )
{ {
if ( pwallet != NULL ) if ( pwallet != NULL )
nThreads = 1; nThreads = 1;

View File

@@ -339,22 +339,25 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
//if (nGenProcLimit == 0) //if (nGenProcLimit == 0)
// fGenerate = false; // fGenerate = false;
} }
if ( ASSETCHAINS_LWMAPOS != 0 )
if (fGenerate && !nGenProcLimit)
{ {
VERUS_MINTBLOCKS = 1; if (fGenerate && !nGenProcLimit)
fGenerate = GetBoolArg("-gen", false); {
if ( ASSETCHAINS_STAKED == 0 ) VERUS_MINTBLOCKS = 1;
nGenProcLimit = KOMODO_MININGTHREADS; fGenerate = GetBoolArg("-gen", false);
else
KOMODO_MININGTHREADS = nGenProcLimit; KOMODO_MININGTHREADS = nGenProcLimit;
}
else if (!fGenerate)
{
VERUS_MINTBLOCKS = 0;
KOMODO_MININGTHREADS = 0;
}
else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
} }
else if (!fGenerate) else
{ {
VERUS_MINTBLOCKS = 0; KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
KOMODO_MININGTHREADS = 0;
} }
else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
mapArgs["-gen"] = (fGenerate ? "1" : "0"); mapArgs["-gen"] = (fGenerate ? "1" : "0");
mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS);

View File

@@ -169,9 +169,9 @@ void AsyncRPCOperation_sendmany::main() {
#ifdef ENABLE_MINING #ifdef ENABLE_MINING
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 0)); GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 1));
#else #else
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 0)); GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 1));
#endif #endif
#endif #endif

View File

@@ -141,9 +141,9 @@ void AsyncRPCOperation_shieldcoinbase::main() {
#ifdef ENABLE_MINING #ifdef ENABLE_MINING
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 0)); GenerateBitcoins(GetBoolArg("-gen",false), pwalletMain, GetArg("-genproclimit", 1));
#else #else
GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 0)); GenerateBitcoins(GetBoolArg("-gen",false), GetArg("-genproclimit", 1));
#endif #endif
#endif #endif

View File

@@ -63,7 +63,7 @@ void post_wallet_load(){
#ifdef ENABLE_MINING #ifdef ENABLE_MINING
// Generate coins in the background // Generate coins in the background
if (pwalletMain || !GetArg("-mineraddress", "").empty()) if (pwalletMain || !GetArg("-mineraddress", "").empty())
GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 0)); GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain, GetArg("-genproclimit", 1));
#endif #endif
} }