Merge pull request #1095 from blackjok3rtt/FSM

Fix setgenerate and proclimit.
This commit is contained in:
jl777
2018-12-16 06:02:05 -11:00
committed by GitHub
4 changed files with 73 additions and 64 deletions

View File

@@ -1874,9 +1874,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
VERUS_MINTBLOCKS = GetBoolArg("-mint", false); VERUS_MINTBLOCKS = GetBoolArg("-mint", false);
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));
#else #else
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 0)); GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", -1));
#endif #endif
#endif #endif

View File

@@ -1657,11 +1657,9 @@ void komodo_args(char *argv0)
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0;
IS_KOMODO_NOTARY = GetBoolArg("-notary", false); IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
if ( GetBoolArg("-gen", false) != 0 )\ if ( GetBoolArg("-gen", false) != 0 )
{ {
KOMODO_MININGTHREADS = GetArg("-genproclimit",-1); KOMODO_MININGTHREADS = GetArg("-genproclimit",-1);
if (KOMODO_MININGTHREADS == 0)
mapArgs["-gen"] = "0";
} }
else KOMODO_MININGTHREADS = 0; else KOMODO_MININGTHREADS = 0;
@@ -1679,6 +1677,8 @@ void komodo_args(char *argv0)
if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 ) if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 )
{ {
IS_KOMODO_NOTARY = 1; IS_KOMODO_NOTARY = 1;
KOMODO_MININGTHREADS = 1;
mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS);
fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]); fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]);
break; break;
} }
@@ -1781,8 +1781,9 @@ void komodo_args(char *argv0)
// for now, we only support 50% PoS due to other parts of the algorithm needing adjustment for // for now, we only support 50% PoS due to other parts of the algorithm needing adjustment for
// other values // other values
if ( (ASSETCHAINS_LWMAPOS = GetArg("-ac_veruspos",0)) != 0 ) if ( (ASSETCHAINS_LWMAPOS = GetArg("-ac_veruspos",0)) != 0 )
{
ASSETCHAINS_LWMAPOS = 50; ASSETCHAINS_LWMAPOS = 50;
}
ASSETCHAINS_SAPLING = GetArg("-ac_sapling", -1); ASSETCHAINS_SAPLING = GetArg("-ac_sapling", -1);
if (ASSETCHAINS_SAPLING == -1) if (ASSETCHAINS_SAPLING == -1)
{ {

View File

@@ -1831,8 +1831,13 @@ 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 ( nThreads == 0 && ASSETCHAINS_STAKED ) if ( ASSETCHAINS_STAKED > 0 && nThreads == 0 )
nThreads = 1; {
if ( pwallet != NULL )
nThreads = 1;
else
return;
}
if ((nThreads == 0 || !fGenerate) && (VERUS_MINTBLOCKS == 0 || pwallet == NULL)) if ((nThreads == 0 || !fGenerate) && (VERUS_MINTBLOCKS == 0 || pwallet == NULL))
return; return;

View File

@@ -344,7 +344,10 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
{ {
VERUS_MINTBLOCKS = 1; VERUS_MINTBLOCKS = 1;
fGenerate = GetBoolArg("-gen", false); fGenerate = GetBoolArg("-gen", false);
nGenProcLimit = KOMODO_MININGTHREADS; if ( ASSETCHAINS_STAKED == 0 )
nGenProcLimit = KOMODO_MININGTHREADS;
else
KOMODO_MININGTHREADS = nGenProcLimit;
} }
else if (!fGenerate) else if (!fGenerate)
{ {