Merge pull request #1100 from jl777/FSM

FSM
This commit is contained in:
jl777
2018-12-16 07:42:04 -11:00
committed by GitHub
6 changed files with 87 additions and 65 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

@@ -1373,7 +1373,7 @@ void komodo_passport_iteration()
{ {
static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter,lastinterest; static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter,lastinterest;
int32_t maxseconds = 10; int32_t maxseconds = 10;
FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //CBlockIndex *pindex;
expired = 0; expired = 0;
while ( KOMODO_INITDONE == 0 ) while ( KOMODO_INITDONE == 0 )
{ {

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

@@ -5048,6 +5048,19 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C
auto verifier = libzcash::ProofVerifier::Disabled(); auto verifier = libzcash::ProofVerifier::Disabled();
if ((!CheckBlock(futureblockp,pindex->GetHeight(),pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev)) if ((!CheckBlock(futureblockp,pindex->GetHeight(),pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev))
{ {
static int32_t saplinght = -1;
CBlockIndex *tmpptr;
if ( saplinght == -1 )
saplinght = Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight;
if ( saplinght < 0 )
*futureblockp = 1;
// the problem is when a future sapling block comes in before we detected saplinght
if ( saplinght > 0 && (tmpptr= chainActive.LastTip()) != 0 )
{
fprintf(stderr,"saplinght.%d tipht.%d blockht.%d cmp.%d\n",saplinght,(int32_t)tmpptr->GetHeight(),pindex->GetHeight(),pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720));
if ( pindex->GetHeight() < 0 || pindex->GetHeight() >= saplinght || (tmpptr->GetHeight() > saplinght-720 && tmpptr->GetHeight() < saplinght+720) )
*futureblockp = 1;
}
if ( *futureblockp == 0 ) if ( *futureblockp == 0 )
{ {
if (state.IsInvalid() && !state.CorruptionPossible()) { if (state.IsInvalid() && !state.CorruptionPossible()) {

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)
{ {