KOMODO_MININGTHREADS to control staking vs PoW, delay start mining by 15 seconds
This commit is contained in:
@@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34];
|
|||||||
#define _COINBASE_MATURITY 100
|
#define _COINBASE_MATURITY 100
|
||||||
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||||
|
|
||||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND;
|
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND;
|
||||||
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,JUMBLR_PAUSE = 1;
|
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,JUMBLR_PAUSE = 1;
|
||||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
|
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
|
||||||
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
|
||||||
|
|||||||
@@ -1505,6 +1505,9 @@ void komodo_args(char *argv0)
|
|||||||
extern const char *Notaries_elected1[][2];
|
extern const char *Notaries_elected1[][2];
|
||||||
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*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[256],*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 )
|
||||||
|
KOMODO_MININGTHREADS = GetArg("-genproclimit",1);
|
||||||
|
else KOMODO_MININGTHREADS = 0;
|
||||||
if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 )
|
if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 )
|
||||||
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");
|
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");
|
||||||
DONATION_PUBKEY = GetArg("-donation", "");
|
DONATION_PUBKEY = GetArg("-donation", "");
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
|||||||
|
|
||||||
#include "komodo_defs.h"
|
#include "komodo_defs.h"
|
||||||
|
|
||||||
extern int32_t KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE;
|
||||||
extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED;
|
extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED;
|
||||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||||
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY;
|
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY;
|
||||||
@@ -393,7 +393,7 @@ 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());
|
||||||
//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);
|
||||||
if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0 )
|
if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 )
|
||||||
{
|
{
|
||||||
uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid,revtxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr;
|
uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid,revtxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr;
|
||||||
CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
|
CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
|
||||||
@@ -453,7 +453,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
|||||||
// Fill in header
|
// Fill in header
|
||||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||||
pblock->hashReserved = uint256();
|
pblock->hashReserved = uint256();
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || GetArg("-genproclimit", 0) > 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || KOMODO_MININGTHREADS > 0 )
|
||||||
{
|
{
|
||||||
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||||
@@ -788,7 +788,7 @@ void static BitcoinMiner()
|
|||||||
}
|
}
|
||||||
if (!fvNodesEmpty )//&& !IsInitialBlockDownload())
|
if (!fvNodesEmpty )//&& !IsInitialBlockDownload())
|
||||||
break;
|
break;
|
||||||
MilliSleep(5000);
|
MilliSleep(15000);
|
||||||
//fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,ASSETCHAINS_SYMBOL,(int32_t)IsInitialBlockDownload());
|
//fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,ASSETCHAINS_SYMBOL,(int32_t)IsInitialBlockDownload());
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
@@ -950,7 +950,7 @@ void static BitcoinMiner()
|
|||||||
// (x_1, x_2, ...) = A(I, V, n, k)
|
// (x_1, x_2, ...) = A(I, V, n, k)
|
||||||
LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString());
|
LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString());
|
||||||
arith_uint256 hashTarget;
|
arith_uint256 hashTarget;
|
||||||
if ( GetArg("-genproclimit", 0) > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 )
|
if ( KOMODO_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 )
|
||||||
hashTarget = HASHTarget_POW;
|
hashTarget = HASHTarget_POW;
|
||||||
else hashTarget = HASHTarget;
|
else hashTarget = HASHTarget;
|
||||||
std::function<bool(std::vector<unsigned char>)> validBlock =
|
std::function<bool(std::vector<unsigned char>)> validBlock =
|
||||||
@@ -978,7 +978,7 @@ void static BitcoinMiner()
|
|||||||
fprintf(stderr," POW\n");*/
|
fprintf(stderr," POW\n");*/
|
||||||
if ( h > hashTarget )
|
if ( h > hashTarget )
|
||||||
{
|
{
|
||||||
//if ( ASSETCHAINS_STAKED != 0 && GetArg("-genproclimit", 0) == 0 )
|
//if ( ASSETCHAINS_STAKED != 0 && KOMODO_MININGTHREADS == 0 )
|
||||||
// sleep(1);
|
// sleep(1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern uint64_t ASSETCHAINS_STAKED;
|
extern uint64_t ASSETCHAINS_STAKED;
|
||||||
|
extern int32_t KOMODO_MININGTHREADS;
|
||||||
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
|
arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -327,6 +328,9 @@ UniValue setgenerate(const UniValue& params, bool fHelp)
|
|||||||
|
|
||||||
mapArgs["-gen"] = (fGenerate ? "1" : "0");
|
mapArgs["-gen"] = (fGenerate ? "1" : "0");
|
||||||
mapArgs ["-genproclimit"] = itostr(nGenProcLimit);
|
mapArgs ["-genproclimit"] = itostr(nGenProcLimit);
|
||||||
|
if ( fGenerate == 0 )
|
||||||
|
KOMODO_MININGTHREADS = -1;
|
||||||
|
else KOMODO_MININGTHREADS = (int32_t)nGenProcLimit;
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit);
|
GenerateBitcoins(fGenerate, pwalletMain, nGenProcLimit);
|
||||||
#else
|
#else
|
||||||
@@ -382,6 +386,7 @@ UniValue getmininginfo(const UniValue& params, bool fHelp)
|
|||||||
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
obj.push_back(Pair("chain", Params().NetworkIDString()));
|
||||||
#ifdef ENABLE_MINING
|
#ifdef ENABLE_MINING
|
||||||
obj.push_back(Pair("generate", getgenerate(params, false)));
|
obj.push_back(Pair("generate", getgenerate(params, false)));
|
||||||
|
obj.push_back(Pair("numthreads", (int64_t)KOMODO_MININGTHREADS));
|
||||||
#endif
|
#endif
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@@ -647,7 +652,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||||||
pblocktemplate = CreateNewBlockWithKey();
|
pblocktemplate = CreateNewBlockWithKey();
|
||||||
#endif
|
#endif
|
||||||
if (!pblocktemplate)
|
if (!pblocktemplate)
|
||||||
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory");
|
throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory or no available utxo for staking");
|
||||||
|
|
||||||
// Need to update only after we know CreateNewBlockWithKey succeeded
|
// Need to update only after we know CreateNewBlockWithKey succeeded
|
||||||
pindexPrev = pindexPrevNew;
|
pindexPrev = pindexPrevNew;
|
||||||
|
|||||||
Reference in New Issue
Block a user