hygiene: Phase 3 follow-up — sweep commented-out debug cruft
Remove ~116 commented-out debug/dead-code lines the audit flagged as noise (findings F6/F7/F15/F22): the Komodo "%s tikN" step-tracer comments and other commented-out fprintf/printf/LogPrintf/std::cerr calls threaded through AppInit2 (init.cpp), CreateNewBlock and the miner loops (miner.cpp), plus a few commented-out dead-code fragments (sendmany SetLockTime/nLockTime, the CCtx CC_vinselect random-pick block and AddNormalinputsLocal remote-mypk redirect, miner adaptive-PoW assignments). Comments only — no compiled behavior changes; the tree builds clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -72,11 +72,6 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *
|
|||||||
abovei = belowi = -1;
|
abovei = belowi = -1;
|
||||||
for (above=below=i=0; i<numunspents; i++)
|
for (above=below=i=0; i<numunspents; i++)
|
||||||
{
|
{
|
||||||
// Filter to randomly pick utxo to avoid conflicts, and having multiple CC choose the same ones.
|
|
||||||
//if ( numunspents > 200 ) {
|
|
||||||
// if ( (rand() % 100) < 90 )
|
|
||||||
// continue;
|
|
||||||
//}
|
|
||||||
if ( (atx_value= utxos[i].nValue) <= 0 )
|
if ( (atx_value= utxos[i].nValue) <= 0 )
|
||||||
continue;
|
continue;
|
||||||
if ( atx_value == value )
|
if ( atx_value == value )
|
||||||
@@ -103,13 +98,11 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *
|
|||||||
belowi = i;
|
belowi = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf("value %.8f gap %.8f abovei.%d %.8f belowi.%d %.8f\n",dstr(value),dstr(gap),abovei,dstr(above),belowi,dstr(below));
|
|
||||||
}
|
}
|
||||||
*aboveip = abovei;
|
*aboveip = abovei;
|
||||||
*abovep = above;
|
*abovep = above;
|
||||||
*belowip = belowi;
|
*belowip = belowi;
|
||||||
*belowp = below;
|
*belowp = below;
|
||||||
//printf("above.%d below.%d\n",abovei,belowi);
|
|
||||||
if ( abovei >= 0 && belowi >= 0 )
|
if ( abovei >= 0 && belowi >= 0 )
|
||||||
{
|
{
|
||||||
if ( above < (below >> 1) )
|
if ( above < (below >> 1) )
|
||||||
@@ -127,8 +120,6 @@ int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total
|
|||||||
if ( HUSH_NSPV_SUPERLITE )
|
if ( HUSH_NSPV_SUPERLITE )
|
||||||
return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U));
|
return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U));
|
||||||
|
|
||||||
// if (mypk != pubkey2pk(Mypubkey())) //remote superlite mypk, do not use wallet since it is not locked for non-equal pks (see rpcs with nspv support)!
|
|
||||||
// return(AddNormalinputs3(mtx, mypk, total, maxinputs));
|
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
assert(pwalletMain != NULL);
|
assert(pwalletMain != NULL);
|
||||||
@@ -150,7 +141,6 @@ int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total
|
|||||||
vout = out.i;
|
vout = out.i;
|
||||||
if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"check %.8f to vins array.%d of %d %s/v%d\n",(double)out.tx->vout[out.i].nValue/COIN,n,maxutxos,txid.GetHex().c_str(),(int32_t)vout);
|
|
||||||
if ( mtx.vin.size() > 0 )
|
if ( mtx.vin.size() > 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<mtx.vin.size(); i++)
|
for (i=0; i<mtx.vin.size(); i++)
|
||||||
@@ -174,7 +164,6 @@ int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total
|
|||||||
up->nValue = out.tx->vout[out.i].nValue;
|
up->nValue = out.tx->vout[out.i].nValue;
|
||||||
up->vout = vout;
|
up->vout = vout;
|
||||||
sum += up->nValue;
|
sum += up->nValue;
|
||||||
//fprintf(stderr,"add %.8f to vins array.%d of %d\n",(double)up->nValue/COIN,n,maxutxos);
|
|
||||||
if ( n >= maxinputs || sum >= total )
|
if ( n >= maxinputs || sum >= total )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -207,14 +196,12 @@ int64_t AddNormalinputsLocal(CMutableTransaction &mtx,CPubKey mypk,int64_t total
|
|||||||
remains -= up->nValue;
|
remains -= up->nValue;
|
||||||
utxos[ind] = utxos[--n];
|
utxos[ind] = utxos[--n];
|
||||||
memset(&utxos[n],0,sizeof(utxos[n]));
|
memset(&utxos[n],0,sizeof(utxos[n]));
|
||||||
//fprintf(stderr,"totalinputs %.8f vs total %.8f i.%d vs max.%d\n",(double)totalinputs/COIN,(double)total/COIN,i,maxinputs);
|
|
||||||
if ( totalinputs >= total || (i+1) >= maxinputs )
|
if ( totalinputs >= total || (i+1) >= maxinputs )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(utxos);
|
free(utxos);
|
||||||
if ( totalinputs >= total )
|
if ( totalinputs >= total )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"return totalinputs %.8f\n",(double)totalinputs/COIN);
|
|
||||||
return(totalinputs);
|
return(totalinputs);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -252,7 +239,6 @@ int64_t AddNormalinputsRemote(CMutableTransaction &mtx, CPubKey mypk, int64_t to
|
|||||||
continue;
|
continue;
|
||||||
if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"check %.8f to vins array.%d of %d %s/v%d\n",(double)out.tx->vout[out.i].nValue/COIN,n,maxutxos,txid.GetHex().c_str(),(int32_t)vout);
|
|
||||||
if ( mtx.vin.size() > 0 )
|
if ( mtx.vin.size() > 0 )
|
||||||
{
|
{
|
||||||
for (i=0; i<mtx.vin.size(); i++)
|
for (i=0; i<mtx.vin.size(); i++)
|
||||||
@@ -276,7 +262,6 @@ int64_t AddNormalinputsRemote(CMutableTransaction &mtx, CPubKey mypk, int64_t to
|
|||||||
up->nValue = it->second.satoshis;
|
up->nValue = it->second.satoshis;
|
||||||
up->vout = vout;
|
up->vout = vout;
|
||||||
sum += up->nValue;
|
sum += up->nValue;
|
||||||
//fprintf(stderr,"add %.8f to vins array.%d of %d\n",(double)up->nValue/COIN,n,maxutxos);
|
|
||||||
if ( n >= maxinputs || sum >= total )
|
if ( n >= maxinputs || sum >= total )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -308,14 +293,12 @@ int64_t AddNormalinputsRemote(CMutableTransaction &mtx, CPubKey mypk, int64_t to
|
|||||||
remains -= up->nValue;
|
remains -= up->nValue;
|
||||||
utxos[ind] = utxos[--n];
|
utxos[ind] = utxos[--n];
|
||||||
memset(&utxos[n],0,sizeof(utxos[n]));
|
memset(&utxos[n],0,sizeof(utxos[n]));
|
||||||
//fprintf(stderr,"totalinputs %.8f vs total %.8f i.%d vs max.%d\n",(double)totalinputs/COIN,(double)total/COIN,i,maxinputs);
|
|
||||||
if ( totalinputs >= total || (i+1) >= maxinputs )
|
if ( totalinputs >= total || (i+1) >= maxinputs )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
free(utxos);
|
free(utxos);
|
||||||
if ( totalinputs >= total )
|
if ( totalinputs >= total )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"return totalinputs %.8f\n",(double)totalinputs/COIN);
|
|
||||||
return(totalinputs);
|
return(totalinputs);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
|
|||||||
30
src/init.cpp
30
src/init.cpp
@@ -1124,7 +1124,6 @@ static void AdjustCoinCacheForMemoryPressure()
|
|||||||
|
|
||||||
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"%s start\n", __FUNCTION__);
|
|
||||||
// ********************************************************* Step 1: setup
|
// ********************************************************* Step 1: setup
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
// Turn off Microsoft heap dump noise
|
// Turn off Microsoft heap dump noise
|
||||||
@@ -1161,7 +1160,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
return InitError("Error: -sysperms is not allowed in combination with enabled wallet functionality");
|
return InitError("Error: -sysperms is not allowed in combination with enabled wallet functionality");
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
//fprintf(stderr,"%s setting umask\n", __FUNCTION__);
|
|
||||||
umask(077);
|
umask(077);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1179,12 +1177,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
|
|
||||||
std::set_new_handler(new_handler_terminate);
|
std::set_new_handler(new_handler_terminate);
|
||||||
|
|
||||||
//fprintf(stderr,"%s: set signal handlers\n", __FUNCTION__);
|
|
||||||
|
|
||||||
// ********************************************************* Step 2: parameter interactions
|
// ********************************************************* Step 2: parameter interactions
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
|
|
||||||
//fprintf(stderr,"%s: got chain params\n", __FUNCTION__);
|
|
||||||
|
|
||||||
// Set this early so that experimental features are correctly enabled/disabled
|
// Set this early so that experimental features are correctly enabled/disabled
|
||||||
fExperimentalMode = GetBoolArg("-experimentalfeatures", true);
|
fExperimentalMode = GetBoolArg("-experimentalfeatures", true);
|
||||||
@@ -1199,7 +1195,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
return InitError(_("Wallet encryption requires -experimentalfeatures."));
|
return InitError(_("Wallet encryption requires -experimentalfeatures."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"%s tik2\n", __FUNCTION__);
|
|
||||||
|
|
||||||
// Set this early so that parameter interactions go to console
|
// Set this early so that parameter interactions go to console
|
||||||
fPrintToConsole = GetBoolArg("-printtoconsole", false);
|
fPrintToConsole = GetBoolArg("-printtoconsole", false);
|
||||||
@@ -1228,7 +1223,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
LogPrintf("%s: parameter interaction: -allowbind set -> setting -listen=1\n", __func__);
|
LogPrintf("%s: parameter interaction: -allowbind set -> setting -listen=1\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik3\n", __FUNCTION__);
|
|
||||||
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) {
|
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) {
|
||||||
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
||||||
if (SoftSetBoolArg("-dnsseed", false))
|
if (SoftSetBoolArg("-dnsseed", false))
|
||||||
@@ -1351,12 +1345,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (SoftSetBoolArg("-rescan", true))
|
if (SoftSetBoolArg("-rescan", true))
|
||||||
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
|
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"%s tik4\n", __FUNCTION__);
|
|
||||||
|
|
||||||
// Make sure enough file descriptors are available
|
// Make sure enough file descriptors are available
|
||||||
int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-allowbind"), 1);
|
int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-allowbind"), 1);
|
||||||
nMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
|
nMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
|
||||||
//fprintf(stderr,"nMaxConnections %d\n",nMaxConnections);
|
|
||||||
nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
|
nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
|
||||||
int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS);
|
int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS);
|
||||||
fprintf(stderr,"nMaxConnections %d FD_SETSIZE.%d nBind.%d expr.%d \n",nMaxConnections,FD_SETSIZE,nBind,(int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS));
|
fprintf(stderr,"nMaxConnections %d FD_SETSIZE.%d nBind.%d expr.%d \n",nMaxConnections,FD_SETSIZE,nBind,(int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS));
|
||||||
@@ -1364,7 +1356,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
return InitError(_("Not enough file descriptors available."));
|
return InitError(_("Not enough file descriptors available."));
|
||||||
if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections)
|
if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections)
|
||||||
nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS;
|
nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS;
|
||||||
//fprintf(stderr,"nMaxConnections %d\n",nMaxConnections);
|
|
||||||
// if using block pruning, then disable txindex
|
// if using block pruning, then disable txindex
|
||||||
// also disable the wallet (for now, until SPV support is implemented in wallet)
|
// also disable the wallet (for now, until SPV support is implemented in wallet)
|
||||||
if (GetArg("-prune", 0)) {
|
if (GetArg("-prune", 0)) {
|
||||||
@@ -1413,7 +1404,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
fprintf(stderr,"%s: enabled randomx debug\n", __func__);
|
fprintf(stderr,"%s: enabled randomx debug\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik5\n", __FUNCTION__);
|
|
||||||
// Check for -debugnet
|
// Check for -debugnet
|
||||||
if (GetBoolArg("-debugnet", false))
|
if (GetBoolArg("-debugnet", false))
|
||||||
InitWarning(_("Warning: Unsupported argument -debugnet ignored, use -debug=net."));
|
InitWarning(_("Warning: Unsupported argument -debugnet ignored, use -debug=net."));
|
||||||
@@ -1472,7 +1462,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
LogPrintf("Bulk block streaming: %s\n", fBulkBlockSync ? "enabled" : "disabled");
|
LogPrintf("Bulk block streaming: %s\n", fBulkBlockSync ? "enabled" : "disabled");
|
||||||
|
|
||||||
fServer = GetBoolArg("-server", false);
|
fServer = GetBoolArg("-server", false);
|
||||||
//fprintf(stderr,"%s tik6\n", __FUNCTION__);
|
|
||||||
|
|
||||||
// block pruning; get the amount of disk space (in MB) to allot for block & undo files
|
// block pruning; get the amount of disk space (in MB) to allot for block & undo files
|
||||||
int64_t nSignedPruneTarget = GetArg("-prune", 0) * 1024 * 1024;
|
int64_t nSignedPruneTarget = GetArg("-prune", 0) * 1024 * 1024;
|
||||||
@@ -1560,7 +1549,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
expiryDelta = GetArg("-txexpirydelta", DEFAULT_TX_EXPIRY_DELTA);
|
expiryDelta = GetArg("-txexpirydelta", DEFAULT_TX_EXPIRY_DELTA);
|
||||||
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", true);
|
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", true);
|
||||||
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", false);
|
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", false);
|
||||||
//fprintf(stderr,"%s tik7\n", __FUNCTION__);
|
|
||||||
|
|
||||||
std::string strWalletFile = GetArg("-wallet", "wallet.dat");
|
std::string strWalletFile = GetArg("-wallet", "wallet.dat");
|
||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
@@ -1577,7 +1565,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
nLocalServices |= NODE_BLOOM;
|
nLocalServices |= NODE_BLOOM;
|
||||||
}
|
}
|
||||||
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
|
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
|
||||||
//fprintf(stderr,"%s tik8\n", __FUNCTION__);
|
|
||||||
|
|
||||||
#ifdef ENABLE_MINING
|
#ifdef ENABLE_MINING
|
||||||
if (mapArgs.count("-mineraddress")) {
|
if (mapArgs.count("-mineraddress")) {
|
||||||
@@ -1600,7 +1587,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik9\n", __FUNCTION__);
|
|
||||||
if (!mapMultiArgs["-nuparams"].empty()) {
|
if (!mapMultiArgs["-nuparams"].empty()) {
|
||||||
// Allow overriding network upgrade parameters for testing
|
// Allow overriding network upgrade parameters for testing
|
||||||
if (Params().NetworkIDString() != "regtest") {
|
if (Params().NetworkIDString() != "regtest") {
|
||||||
@@ -1649,7 +1635,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
std::string sha256_algo = SHA256AutoDetect();
|
std::string sha256_algo = SHA256AutoDetect();
|
||||||
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo);
|
LogPrintf("Using the '%s' SHA256 implementation\n", sha256_algo);
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik10\n", __FUNCTION__);
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (!InitSanityCheck())
|
if (!InitSanityCheck())
|
||||||
return InitError(_("Initialization sanity check failed. Please check for insanity. Hush is shutting down!"));
|
return InitError(_("Initialization sanity check failed. Please check for insanity. Hush is shutting down!"));
|
||||||
@@ -1666,7 +1651,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (file) fclose(file);
|
if (file) fclose(file);
|
||||||
|
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik11\n", __FUNCTION__);
|
|
||||||
fprintf(stderr,"Attempting to obtain lock %s\n", pathLockFile.string().c_str());
|
fprintf(stderr,"Attempting to obtain lock %s\n", pathLockFile.string().c_str());
|
||||||
try {
|
try {
|
||||||
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
|
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
|
||||||
@@ -1682,7 +1666,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (GetBoolArg("-shrinkdebugfile", !fDebug))
|
if (GetBoolArg("-shrinkdebugfile", !fDebug))
|
||||||
ShrinkDebugFile();
|
ShrinkDebugFile();
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik12\n", __FUNCTION__);
|
|
||||||
|
|
||||||
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||||
LogPrintf("Hush version %s\n", FormatFullVersion());
|
LogPrintf("Hush version %s\n", FormatFullVersion());
|
||||||
@@ -1715,7 +1698,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
threadGroup.create_thread(&ThreadRandomXVerify);
|
threadGroup.create_thread(&ThreadRandomXVerify);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik13\n", __FUNCTION__);
|
|
||||||
|
|
||||||
// Start the lightweight task scheduler thread
|
// Start the lightweight task scheduler thread
|
||||||
CScheduler::Function serviceLoop = boost::bind(&CScheduler::serviceQueue, &scheduler);
|
CScheduler::Function serviceLoop = boost::bind(&CScheduler::serviceQueue, &scheduler);
|
||||||
@@ -1723,7 +1705,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
|
|
||||||
// Count uptime
|
// Count uptime
|
||||||
MarkStartTime();
|
MarkStartTime();
|
||||||
//fprintf(stderr,"%s tik14\n", __FUNCTION__);
|
|
||||||
|
|
||||||
if ((chainparams.NetworkIDString() != "regtest") &&
|
if ((chainparams.NetworkIDString() != "regtest") &&
|
||||||
GetBoolArg("-showmetrics", 0) &&
|
GetBoolArg("-showmetrics", 0) &&
|
||||||
@@ -1733,7 +1714,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
threadGroup.create_thread(&ThreadShowMetricsScreen);
|
threadGroup.create_thread(&ThreadShowMetricsScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik15\n", __FUNCTION__);
|
|
||||||
|
|
||||||
if ( HUSH_NSPV_FULLNODE )
|
if ( HUSH_NSPV_FULLNODE )
|
||||||
{
|
{
|
||||||
@@ -1751,7 +1731,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
if (!AppInitServers(threadGroup))
|
if (!AppInitServers(threadGroup))
|
||||||
return InitError(_("Unable to start HTTP server. See debug log for details."));
|
return InitError(_("Unable to start HTTP server. See debug log for details."));
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"%s tik16\n", __FUNCTION__);
|
|
||||||
|
|
||||||
int64_t nStart;
|
int64_t nStart;
|
||||||
|
|
||||||
@@ -1778,7 +1757,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
#endif // ENABLE_WALLET
|
#endif // ENABLE_WALLET
|
||||||
// ********************************************************* Step 6: network initialization
|
// ********************************************************* Step 6: network initialization
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik17\n", __FUNCTION__);
|
|
||||||
RegisterNodeSignals(GetNodeSignals());
|
RegisterNodeSignals(GetNodeSignals());
|
||||||
|
|
||||||
// sanitize comments per BIP-0014, format user agent and check total size
|
// sanitize comments per BIP-0014, format user agent and check total size
|
||||||
@@ -1794,7 +1772,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.",
|
return InitError(strprintf("Total length of network version string %i exceeds maximum of %i characters. Reduce the number and/or size of uacomments.",
|
||||||
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
|
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"%s tik18\n", __FUNCTION__);
|
|
||||||
|
|
||||||
// Disable clearnet peers if -clearnet=0 for this node or -ac_clearnet=0 for this chain
|
// Disable clearnet peers if -clearnet=0 for this node or -ac_clearnet=0 for this chain
|
||||||
if (ASSETCHAINS_CLEARNET == 0 || !GetBoolArg("-clearnet", DEFAULT_CLEARNET)) {
|
if (ASSETCHAINS_CLEARNET == 0 || !GetBoolArg("-clearnet", DEFAULT_CLEARNET)) {
|
||||||
@@ -1853,7 +1830,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
SetReachable(NET_IPV4, false);
|
SetReachable(NET_IPV4, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik19\n", __FUNCTION__);
|
|
||||||
if (mapArgs.count("-allowlist")) {
|
if (mapArgs.count("-allowlist")) {
|
||||||
BOOST_FOREACH(const std::string& net, mapMultiArgs["-allowlist"]) {
|
BOOST_FOREACH(const std::string& net, mapMultiArgs["-allowlist"]) {
|
||||||
CSubNet subnet;
|
CSubNet subnet;
|
||||||
@@ -1916,7 +1892,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
fDiscover = GetBoolArg("-discover", true);
|
fDiscover = GetBoolArg("-discover", true);
|
||||||
fNameLookup = GetBoolArg("-dns", true);
|
fNameLookup = GetBoolArg("-dns", true);
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik22\n", __FUNCTION__);
|
|
||||||
bool fBound = false;
|
bool fBound = false;
|
||||||
if (fListen) {
|
if (fListen) {
|
||||||
if (mapArgs.count("-bind") || mapArgs.count("-allowbind")) {
|
if (mapArgs.count("-bind") || mapArgs.count("-allowbind")) {
|
||||||
@@ -1955,7 +1930,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik23\n", __FUNCTION__);
|
|
||||||
|
|
||||||
BOOST_FOREACH(const std::string& strDest, mapMultiArgs["-seednode"])
|
BOOST_FOREACH(const std::string& strDest, mapMultiArgs["-seednode"])
|
||||||
AddOneShot(strDest);
|
AddOneShot(strDest);
|
||||||
@@ -1991,7 +1965,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
return !fRequestShutdown;
|
return !fRequestShutdown;
|
||||||
}
|
}
|
||||||
// ********************************************************* Step 7: load block chain
|
// ********************************************************* Step 7: load block chain
|
||||||
//fprintf(stderr,"%s tik24\n", __FUNCTION__);
|
|
||||||
|
|
||||||
fReindex = GetBoolArg("-reindex", false);
|
fReindex = GetBoolArg("-reindex", false);
|
||||||
|
|
||||||
@@ -2238,7 +2211,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
mempool.ReadFeeEstimates(est_filein);
|
mempool.ReadFeeEstimates(est_filein);
|
||||||
fFeeEstimatesInitialized = true;
|
fFeeEstimatesInitialized = true;
|
||||||
|
|
||||||
//fprintf(stderr,"%s tik25\n", __FUNCTION__);
|
|
||||||
|
|
||||||
// ********************************************************* Step 8: load wallet
|
// ********************************************************* Step 8: load wallet
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
@@ -2452,7 +2424,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < vSweep.size(); i++) {
|
for (int i = 0; i < vSweep.size(); i++) {
|
||||||
// LogPrintf("Sweep Address: %s\n", vSweep[i]);
|
|
||||||
auto zSweep = DecodePaymentAddress(vSweep[i]);
|
auto zSweep = DecodePaymentAddress(vSweep[i]);
|
||||||
if (!IsValidPaymentAddress(zSweep)) {
|
if (!IsValidPaymentAddress(zSweep)) {
|
||||||
return InitError("Invalid zsweep address");
|
return InitError("Invalid zsweep address");
|
||||||
@@ -2800,7 +2771,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
|||||||
|
|
||||||
// ********************************************************* Step 11: start node
|
// ********************************************************* Step 11: start node
|
||||||
|
|
||||||
//fprintf(stderr,"Checking disk space...\n");
|
|
||||||
if (!CheckDiskSpace())
|
if (!CheckDiskSpace())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ bool hush_appendACscriptpub();
|
|||||||
|
|
||||||
CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake)
|
CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32_t gpucount, bool isStake)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"%s\n", __func__);
|
|
||||||
CScript scriptPubKeyIn(_scriptPubKeyIn);
|
CScript scriptPubKeyIn(_scriptPubKeyIn);
|
||||||
|
|
||||||
CPubKey pk;
|
CPubKey pk;
|
||||||
@@ -179,12 +178,10 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
uint32_t blocktime; const CChainParams& chainparams = Params();
|
uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||||
bool fNotarizationBlock = false; std::vector<int8_t> NotarizationNotaries;
|
bool fNotarizationBlock = false; std::vector<int8_t> NotarizationNotaries;
|
||||||
|
|
||||||
//fprintf(stderr,"%s: create new block with pubkey=%s\n", __func__, HexStr(pk).c_str());
|
|
||||||
// Create new block
|
// Create new block
|
||||||
if ( gpucount < 0 )
|
if ( gpucount < 0 )
|
||||||
gpucount = HUSH_MAXGPUCOUNT;
|
gpucount = HUSH_MAXGPUCOUNT;
|
||||||
std::unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
std::unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
||||||
//fprintf(stderr,"%s: created new block template\n", __func__);
|
|
||||||
if(!pblocktemplate.get())
|
if(!pblocktemplate.get())
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%s: pblocktemplate.get() failure\n", __func__);
|
fprintf(stderr,"%s: pblocktemplate.get() failure\n", __func__);
|
||||||
@@ -200,7 +197,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
pblock->vtx.push_back(CTransaction());
|
pblock->vtx.push_back(CTransaction());
|
||||||
pblocktemplate->vTxFees.push_back(-1); // updated at end
|
pblocktemplate->vTxFees.push_back(-1); // updated at end
|
||||||
pblocktemplate->vTxSigOps.push_back(-1); // updated at end
|
pblocktemplate->vTxSigOps.push_back(-1); // updated at end
|
||||||
//fprintf(stderr,"%s: added dummy coinbase\n", __func__);
|
|
||||||
|
|
||||||
// Largest block you're willing to create:
|
// Largest block you're willing to create:
|
||||||
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE(1)); // MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1));
|
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE(1)); // MAX_BLOCK_SIZE(chainActive.LastTip()->GetHeight()+1));
|
||||||
@@ -217,7 +213,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
// until there are no more or the block reaches this size:
|
// until there are no more or the block reaches this size:
|
||||||
const unsigned int nBlockMinSize = std::min(nBlockMaxSize, (unsigned int) GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE));
|
const unsigned int nBlockMinSize = std::min(nBlockMaxSize, (unsigned int) GetArg("-blockminsize", DEFAULT_BLOCK_MIN_SIZE));
|
||||||
// nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
|
// nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
|
||||||
//fprintf(stderr,"%s: nBlockMaxSize=%u, nBlockPrioritySize=%u, nBlockMinSize=%u\n", __func__, nBlockMaxSize, nBlockPrioritySize, nBlockMinSize);
|
|
||||||
|
|
||||||
|
|
||||||
// Collect memory pool transactions into the block
|
// Collect memory pool transactions into the block
|
||||||
@@ -243,7 +238,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
|
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
|
||||||
uint32_t proposedTime = GetTime();
|
uint32_t proposedTime = GetTime();
|
||||||
|
|
||||||
//fprintf(stderr,"%s: nHeight=%d, consensusBranchId=%u, proposedTime=%u\n", __func__, nHeight, consensusBranchId, proposedTime);
|
|
||||||
|
|
||||||
if (proposedTime == nMedianTimePast)
|
if (proposedTime == nMedianTimePast)
|
||||||
{
|
{
|
||||||
@@ -282,7 +276,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
vector<TxPriority> vecPriority;
|
vector<TxPriority> vecPriority;
|
||||||
vecPriority.reserve(mempool.mapTx.size() + 1);
|
vecPriority.reserve(mempool.mapTx.size() + 1);
|
||||||
|
|
||||||
//fprintf(stderr,"%s: going to add txs from mempool\n", __func__);
|
|
||||||
// now add transactions from the mempool
|
// now add transactions from the mempool
|
||||||
int32_t Notarizations = 0; uint64_t txvalue;
|
int32_t Notarizations = 0; uint64_t txvalue;
|
||||||
uint32_t large_zins = 0; // number of ztxs with large number of inputs in block
|
uint32_t large_zins = 0; // number of ztxs with large number of inputs in block
|
||||||
@@ -392,7 +385,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
// Priority is sum(valuein * age) / modified_txsize
|
// Priority is sum(valuein * age) / modified_txsize
|
||||||
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
// fprintf(stderr,"%s: computing priority with nTxSize=%u\n", __func__, nTxSize);
|
|
||||||
dPriority = tx.ComputePriority(dPriority, nTxSize);
|
dPriority = tx.ComputePriority(dPriority, nTxSize);
|
||||||
|
|
||||||
uint256 hash = tx.GetHash();
|
uint256 hash = tx.GetHash();
|
||||||
@@ -423,7 +415,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
NotarizationNotaries = TMP_NotarizationNotaries;
|
NotarizationNotaries = TMP_NotarizationNotaries;
|
||||||
dPriority = 1e16;
|
dPriority = 1e16;
|
||||||
fNotarizationBlock = true;
|
fNotarizationBlock = true;
|
||||||
//fprintf(stderr, "Notarization %s set to maximum priority\n",hash.ToString().c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -438,7 +429,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx())));
|
vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fprintf(stderr,"%s: done adding txs from mempool\n", __func__);
|
|
||||||
|
|
||||||
// Collect transactions into block
|
// Collect transactions into block
|
||||||
int64_t interest;
|
int64_t interest;
|
||||||
@@ -450,7 +440,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
TxPriorityCompare comparer(fSortedByFee);
|
TxPriorityCompare comparer(fSortedByFee);
|
||||||
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||||
|
|
||||||
// fprintf(stderr,"%s: compared txs with fSortedByFee=%d\n", __func__, fSortedByFee);
|
|
||||||
|
|
||||||
while (!vecPriority.empty()) {
|
while (!vecPriority.empty()) {
|
||||||
// Take highest priority transaction off the priority queue:
|
// Take highest priority transaction off the priority queue:
|
||||||
@@ -458,10 +447,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
CFeeRate feeRate = vecPriority.front().get<1>();
|
CFeeRate feeRate = vecPriority.front().get<1>();
|
||||||
const CTransaction& tx = *(vecPriority.front().get<2>());
|
const CTransaction& tx = *(vecPriority.front().get<2>());
|
||||||
|
|
||||||
// fprintf(stderr,"%s: grabbed first tx from priority queue\n", __func__);
|
|
||||||
|
|
||||||
std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||||
// fprintf(stderr,"%s: compared first tx from priority queue\n", __func__);
|
|
||||||
vecPriority.pop_back();
|
vecPriority.pop_back();
|
||||||
|
|
||||||
if(tx.vShieldedSpend.size() >= LARGE_ZINS_THRESHOLD && large_zins >= LARGE_ZINS_MAX) {
|
if(tx.vShieldedSpend.size() >= LARGE_ZINS_THRESHOLD && large_zins >= LARGE_ZINS_MAX) {
|
||||||
@@ -478,7 +465,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
// Size limits
|
// Size limits
|
||||||
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||||
// fprintf(stderr,"%s: nTxSize = %u\n", __func__, nTxSize);
|
|
||||||
|
|
||||||
|
|
||||||
if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx
|
if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx
|
||||||
@@ -491,11 +477,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
unsigned int nTxSigOps = GetLegacySigOpCount(tx);
|
unsigned int nTxSigOps = GetLegacySigOpCount(tx);
|
||||||
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1)
|
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"A nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fprintf(stderr,"%s: looking to see if we need to skip any fee=0 txs\n", __func__);
|
|
||||||
|
|
||||||
// Skip free transactions if we're past the minimum block size:
|
// Skip free transactions if we're past the minimum block size:
|
||||||
const uint256& hash = tx.GetHash();
|
const uint256& hash = tx.GetHash();
|
||||||
@@ -518,7 +502,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
if (!view.HaveInputs(tx))
|
if (!view.HaveInputs(tx))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"dont have inputs\n");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut();
|
CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut();
|
||||||
@@ -560,7 +543,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
nTxSigOps += GetP2SHSigOpCount(tx, view);
|
nTxSigOps += GetP2SHSigOpCount(tx, view);
|
||||||
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1)
|
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"B nBlockSigOps %d + %d nTxSigOps >= %d MAX_BLOCK_SIGOPS-1\n",(int32_t)nBlockSigOps,(int32_t)nTxSigOps,(int32_t)MAX_BLOCK_SIGOPS);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Note that flags: we don't want to set mempool/IsStandard()
|
// Note that flags: we don't want to set mempool/IsStandard()
|
||||||
@@ -625,13 +607,11 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
nLastBlockTx = nBlockTx;
|
nLastBlockTx = nBlockTx;
|
||||||
nLastBlockSize = nBlockSize;
|
nLastBlockSize = nBlockSize;
|
||||||
// fprintf(stderr,"%s: nLastBlockTx=%lu , nLastBlockSize=%lu\n", __func__, nLastBlockTx, nLastBlockSize);
|
|
||||||
|
|
||||||
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
|
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
|
||||||
blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetTime());
|
blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetTime());
|
||||||
else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetTime());
|
else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetTime());
|
||||||
//pblock->nTime = blocktime + 1;
|
//pblock->nTime = blocktime + 1;
|
||||||
// fprintf(stderr,"%s: calling GetNextWorkRequired\n", __func__);
|
|
||||||
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);
|
||||||
@@ -645,7 +625,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
txNew.vout.resize(1);
|
txNew.vout.resize(1);
|
||||||
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
txNew.vout[0].scriptPubKey = scriptPubKeyIn;
|
||||||
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
|
txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees;
|
||||||
// fprintf(stderr,"%s: mine ht.%d with %.8f\n",__func__,nHeight,(double)txNew.vout[0].nValue/COIN);
|
|
||||||
txNew.nExpiryHeight = 0;
|
txNew.nExpiryHeight = 0;
|
||||||
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
|
if ( ASSETCHAINS_ADAPTIVEPOW <= 0 )
|
||||||
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime());
|
txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime());
|
||||||
@@ -670,7 +649,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
fprintf(stderr, "appended ccopreturn to assetchains_scriptpub.%s\n", assetchains_scriptpub.c_str());
|
fprintf(stderr, "appended ccopreturn to assetchains_scriptpub.%s\n", assetchains_scriptpub.c_str());
|
||||||
didinit = true;
|
didinit = true;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"mine to -ac_script\n");
|
|
||||||
//txNew.vout[1].scriptPubKey = CScript() << ParseHex();
|
//txNew.vout[1].scriptPubKey = CScript() << ParseHex();
|
||||||
int32_t len = strlen(assetchains_scriptpub.c_str());
|
int32_t len = strlen(assetchains_scriptpub.c_str());
|
||||||
len >>= 1;
|
len >>= 1;
|
||||||
@@ -684,12 +662,9 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
for (i=0; i<33; i++)
|
for (i=0; i<33; i++)
|
||||||
{
|
{
|
||||||
ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i];
|
ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i];
|
||||||
//fprintf(stderr,"%02x",ptr[i+1]);
|
|
||||||
}
|
}
|
||||||
ptr[34] = OP_CHECKSIG;
|
ptr[34] = OP_CHECKSIG;
|
||||||
//fprintf(stderr," set ASSETCHAINS_OVERRIDE_PUBKEY33 into vout[1]\n");
|
|
||||||
}
|
}
|
||||||
//printf("autocreate commision vout\n");
|
|
||||||
} else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) {
|
} else if ( (uint64_t)(txNew.vout[0].nValue) >= ASSETCHAINS_TIMELOCKGTE) {
|
||||||
fprintf(stderr,"timelocked chains not supported in this code!\n");
|
fprintf(stderr,"timelocked chains not supported in this code!\n");
|
||||||
LEAVE_CRITICAL_SECTION(cs_main);
|
LEAVE_CRITICAL_SECTION(cs_main);
|
||||||
@@ -712,7 +687,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
//fprintf(stderr, "Created notary payment coinbase totalsat.%lu\n",totalsats);
|
|
||||||
} else fprintf(stderr, "vout 2 of notarization is not OP_RETURN scriptlen.%i\n", scriptlen);
|
} else fprintf(stderr, "vout 2 of notarization is not OP_RETURN scriptlen.%i\n", scriptlen);
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_CBOPRET != 0 )
|
if ( ASSETCHAINS_CBOPRET != 0 )
|
||||||
@@ -721,7 +695,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
txNew.vout.resize(numv+1);
|
txNew.vout.resize(numv+1);
|
||||||
txNew.vout[numv].nValue = 0;
|
txNew.vout[numv].nValue = 0;
|
||||||
txNew.vout[numv].scriptPubKey = hush_mineropret(nHeight);
|
txNew.vout[numv].scriptPubKey = hush_mineropret(nHeight);
|
||||||
//printf("autocreate commision/cbopret.%lld vout[%d]\n",(long long)ASSETCHAINS_CBOPRET,(int32_t)txNew.vout.size());
|
|
||||||
}
|
}
|
||||||
pblock->vtx[0] = txNew;
|
pblock->vtx[0] = txNew;
|
||||||
pblocktemplate->vTxFees[0] = -nFees;
|
pblocktemplate->vTxFees[0] = -nFees;
|
||||||
@@ -754,7 +727,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && (IS_HUSH_NOTARY == 0 || My_notaryid < 0) )
|
if ( ASSETCHAINS_CC == 0 && pindexPrev != 0 && (IS_HUSH_NOTARY == 0 || My_notaryid < 0) )
|
||||||
{
|
{
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
//fprintf(stderr,"%s: check validity\n", __func__);
|
|
||||||
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) // invokes CC checks
|
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) // invokes CC checks
|
||||||
{
|
{
|
||||||
if ( !isStake )
|
if ( !isStake )
|
||||||
@@ -766,14 +738,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
//throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); // crashes the node, moved to GetBlockTemplate and issue return.
|
//throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); // crashes the node, moved to GetBlockTemplate and issue return.
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"valid\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LEAVE_CRITICAL_SECTION(cs_main);
|
LEAVE_CRITICAL_SECTION(cs_main);
|
||||||
LEAVE_CRITICAL_SECTION(mempool.cs);
|
LEAVE_CRITICAL_SECTION(mempool.cs);
|
||||||
|
|
||||||
// fprintf(stderr,"%s: done\n", __func__);
|
|
||||||
return pblocktemplate.release();
|
return pblocktemplate.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -783,7 +753,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
|
void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"RandomXMiner: %s with nExtraNonce=%u\n", __func__, nExtraNonce);
|
|
||||||
// Update nExtraNonce
|
// Update nExtraNonce
|
||||||
static uint256 hashPrevBlock;
|
static uint256 hashPrevBlock;
|
||||||
if (hashPrevBlock != pblock->hashPrevBlock)
|
if (hashPrevBlock != pblock->hashPrevBlock)
|
||||||
@@ -807,7 +776,6 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
|||||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, int32_t gpucount, bool isStake)
|
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight, int32_t gpucount, bool isStake)
|
||||||
{
|
{
|
||||||
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
||||||
// fprintf(stderr,"%s: with nHeight=%d\n", __func__, nHeight);
|
|
||||||
|
|
||||||
// Create a local variable instead of modifying the global assetchains_scriptpub
|
// Create a local variable instead of modifying the global assetchains_scriptpub
|
||||||
auto assetchains_scriptpub = devtax_scriptpub_for_height(nHeight);
|
auto assetchains_scriptpub = devtax_scriptpub_for_height(nHeight);
|
||||||
@@ -817,7 +785,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
{
|
{
|
||||||
pubkey = ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY);
|
pubkey = ParseHex(ASSETCHAINS_OVERRIDE_PUBKEY);
|
||||||
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
|
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
|
||||||
// fprintf(stderr,"%s: with pubkey=%s\n", __func__, HexStr(pubkey).c_str() );
|
|
||||||
} else {
|
} else {
|
||||||
len = strlen(assetchains_scriptpub.c_str());
|
len = strlen(assetchains_scriptpub.c_str());
|
||||||
len >>= 1;
|
len >>= 1;
|
||||||
@@ -826,7 +793,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
decode_hex(ptr,len,(char *)assetchains_scriptpub.c_str());
|
decode_hex(ptr,len,(char *)assetchains_scriptpub.c_str());
|
||||||
}
|
}
|
||||||
} else if ( USE_EXTERNAL_PUBKEY != 0 ) {
|
} else if ( USE_EXTERNAL_PUBKEY != 0 ) {
|
||||||
//fprintf(stderr,"use notary pubkey\n");
|
|
||||||
pubkey = ParseHex(NOTARY_PUBKEY);
|
pubkey = ParseHex(NOTARY_PUBKEY);
|
||||||
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
|
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
|
||||||
} else {
|
} else {
|
||||||
@@ -854,7 +820,6 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fprintf(stderr,"%s: calling CreateNewBlock\n", __func__);
|
|
||||||
return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake);
|
return CreateNewBlock(pubkey, scriptPubKey, gpucount, isStake);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,7 +833,6 @@ void hush_sendmessage(int32_t minpeers,int32_t maxpeers,const char *message,std:
|
|||||||
continue;
|
continue;
|
||||||
if ( numsent < minpeers || (rand() % 10) == 0 )
|
if ( numsent < minpeers || (rand() % 10) == 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"pushmessage\n");
|
|
||||||
pnode->PushMessage(message,payload);
|
pnode->PushMessage(message,payload);
|
||||||
if ( numsent++ > maxpeers )
|
if ( numsent++ > maxpeers )
|
||||||
break;
|
break;
|
||||||
@@ -916,7 +880,6 @@ static bool ProcessBlockFound(CBlock* pblock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//fprintf(stderr,"process new block\n");
|
|
||||||
|
|
||||||
// Process this block the same as if we had received it from another node
|
// Process this block the same as if we had received it from another node
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
@@ -993,7 +956,6 @@ CBlockIndex *get_chainactive(int32_t height)
|
|||||||
}
|
}
|
||||||
// else fprintf(stderr,"get_chainactive height %d > active.%d\n",height,chainActive.Tip()->GetHeight());
|
// else fprintf(stderr,"get_chainactive height %d > active.%d\n",height,chainActive.Tip()->GetHeight());
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"get_chainactive null chainActive.Tip() height %d\n",height);
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1281,13 +1243,11 @@ void static RandomXMiner()
|
|||||||
randomx_vm *myVM = nullptr;
|
randomx_vm *myVM = nullptr;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// fprintf(stderr,"RandomXMiner: mining %s with randomx\n",SMART_CHAIN_SYMBOL);
|
|
||||||
|
|
||||||
rxdebug("%s: mining %s with randomx\n", SMART_CHAIN_SYMBOL);
|
rxdebug("%s: mining %s with randomx\n", SMART_CHAIN_SYMBOL);
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
// fprintf(stderr,"RandomXMiner: beginning mining loop on %s with nExtraNonce=%u\n",SMART_CHAIN_SYMBOL, nExtraNonce);
|
|
||||||
rxdebug("%s: start mining loop on %s with nExtraNonce=%u\n", SMART_CHAIN_SYMBOL, nExtraNonce);
|
rxdebug("%s: start mining loop on %s with nExtraNonce=%u\n", SMART_CHAIN_SYMBOL, nExtraNonce);
|
||||||
|
|
||||||
if (chainparams.MiningRequiresPeers()) {
|
if (chainparams.MiningRequiresPeers()) {
|
||||||
@@ -1305,10 +1265,8 @@ void static RandomXMiner()
|
|||||||
if (!fvNodesEmpty )//&& !IsInitialBlockDownload())
|
if (!fvNodesEmpty )//&& !IsInitialBlockDownload())
|
||||||
break;
|
break;
|
||||||
MilliSleep(15000);
|
MilliSleep(15000);
|
||||||
//fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,SMART_CHAIN_SYMBOL,(int32_t)IsInitialBlockDownload());
|
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
//fprintf(stderr,"%s Found peers\n",SMART_CHAIN_SYMBOL);
|
|
||||||
miningTimer.start();
|
miningTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1333,7 +1291,6 @@ void static RandomXMiner()
|
|||||||
Mining_start = (uint32_t)time(NULL);
|
Mining_start = (uint32_t)time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fprintf(stderr,"RandomXMiner: using initial key with interval=%d and lag=%d\n", randomxInterval, randomxBlockLag);
|
|
||||||
rxdebug("%s: using initial key, interval=%d, lag=%d, Mining_height=%u\n", randomxInterval, randomxBlockLag, Mining_height);
|
rxdebug("%s: using initial key, interval=%d, lag=%d, Mining_height=%u\n", randomxInterval, randomxBlockLag, Mining_height);
|
||||||
// Update the shared dataset key — only one thread will actually rebuild,
|
// Update the shared dataset key — only one thread will actually rebuild,
|
||||||
// others will see the key is already current and skip.
|
// others will see the key is already current and skip.
|
||||||
@@ -1366,14 +1323,12 @@ void static RandomXMiner()
|
|||||||
|
|
||||||
// Acquire shared lock to prevent dataset rebuild while we're hashing
|
// Acquire shared lock to prevent dataset rebuild while we're hashing
|
||||||
boost::shared_lock<boost::shared_mutex> datasetLock(g_rxDatasetManager->datasetMtx);
|
boost::shared_lock<boost::shared_mutex> datasetLock(g_rxDatasetManager->datasetMtx);
|
||||||
//fprintf(stderr,"RandomXMiner: Mining_start=%u\n", Mining_start);
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0);
|
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey, pindexPrev->GetHeight()+1, gpucount, 0);
|
||||||
#else
|
#else
|
||||||
CBlockTemplate *ptr = CreateNewBlockWithKey();
|
CBlockTemplate *ptr = CreateNewBlockWithKey();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// fprintf(stderr,"RandomXMiner: created new block with Mining_start=%u\n",Mining_start);
|
|
||||||
rxdebug("%s: created new block with Mining_start=%u\n",Mining_start);
|
rxdebug("%s: created new block with Mining_start=%u\n",Mining_start);
|
||||||
if ( ptr == 0 )
|
if ( ptr == 0 )
|
||||||
{
|
{
|
||||||
@@ -1390,7 +1345,6 @@ void static RandomXMiner()
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// fprintf(stderr,"RandomXMiner: getting block template\n");
|
|
||||||
rxdebug("%s: getting block template\n");
|
rxdebug("%s: getting block template\n");
|
||||||
|
|
||||||
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
||||||
@@ -1419,7 +1373,6 @@ void static RandomXMiner()
|
|||||||
}
|
}
|
||||||
rxdebug("%s: incrementing extra nonce\n");
|
rxdebug("%s: incrementing extra nonce\n");
|
||||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||||
// fprintf(stderr,"RandomXMiner: %u transactions in block\n",(int32_t)pblock->vtx.size());
|
|
||||||
LogPrintf("Running HushRandomXMiner with %u transactions in block (%u bytes)\n",pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
LogPrintf("Running HushRandomXMiner with %u transactions in block (%u bytes)\n",pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
@@ -1440,7 +1393,6 @@ void static RandomXMiner()
|
|||||||
}
|
}
|
||||||
hush_longestchain();
|
hush_longestchain();
|
||||||
|
|
||||||
// fprintf(stderr,"RandomXMiner: solving with nNonce = %s\n",pblock->nNonce.ToString().c_str());
|
|
||||||
rxdebug("%s: solving with nNonce = %s\n",pblock->nNonce.ToString().c_str());
|
rxdebug("%s: solving with nNonce = %s\n",pblock->nNonce.ToString().c_str());
|
||||||
arith_uint256 hashTarget;
|
arith_uint256 hashTarget;
|
||||||
hashTarget = HASHTarget;
|
hashTarget = HASHTarget;
|
||||||
@@ -1451,7 +1403,6 @@ void static RandomXMiner()
|
|||||||
randomxInput << rxInput;
|
randomxInput << rxInput;
|
||||||
|
|
||||||
// std::cerr << "RandomXMiner: randomxInput=" << HexStr(randomxInput) << "\n";
|
// std::cerr << "RandomXMiner: randomxInput=" << HexStr(randomxInput) << "\n";
|
||||||
// fprintf(stderr,"RandomXMiner: created randomxKey=%s , randomxInput.size=%lu\n", randomxKey, randomxInput.size() ); //randomxInput);
|
|
||||||
rxdebug("%s: randomxKey=%s randomxInput=%s\n", randomxKey, HexStr(randomxInput).c_str());
|
rxdebug("%s: randomxKey=%s randomxInput=%s\n", randomxKey, HexStr(randomxInput).c_str());
|
||||||
|
|
||||||
rxdebug("%s: calculating randomx hash\n");
|
rxdebug("%s: calculating randomx hash\n");
|
||||||
@@ -1480,7 +1431,6 @@ void static RandomXMiner()
|
|||||||
rxdebug("%s: Checking solution against target\n");
|
rxdebug("%s: Checking solution against target\n");
|
||||||
pblock->nSolution = soln;
|
pblock->nSolution = soln;
|
||||||
solutionTargetChecks.increment();
|
solutionTargetChecks.increment();
|
||||||
// fprintf(stderr,"%s: solutionTargetChecks=%lu\n", __func__, solutionTargetChecks.get());
|
|
||||||
B = *pblock;
|
B = *pblock;
|
||||||
h = UintToArith256(B.GetHash());
|
h = UintToArith256(B.GetHash());
|
||||||
|
|
||||||
@@ -1705,10 +1655,8 @@ void static BitcoinMiner()
|
|||||||
if (!fvNodesEmpty )//&& !IsInitialBlockDownload())
|
if (!fvNodesEmpty )//&& !IsInitialBlockDownload())
|
||||||
break;
|
break;
|
||||||
MilliSleep(15000);
|
MilliSleep(15000);
|
||||||
//fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,SMART_CHAIN_SYMBOL,(int32_t)IsInitialBlockDownload());
|
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
//fprintf(stderr,"%s Found peers\n",SMART_CHAIN_SYMBOL);
|
|
||||||
miningTimer.start();
|
miningTimer.start();
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@@ -1731,7 +1679,6 @@ void static BitcoinMiner()
|
|||||||
}
|
}
|
||||||
if ( SMART_CHAIN_SYMBOL[0] != 0 && ASSETCHAINS_STAKED == 0 )
|
if ( SMART_CHAIN_SYMBOL[0] != 0 && ASSETCHAINS_STAKED == 0 )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"%s create new block ht.%d\n",SMART_CHAIN_SYMBOL,Mining_height);
|
|
||||||
//sleep(3);
|
//sleep(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1756,7 +1703,6 @@ void static BitcoinMiner()
|
|||||||
sleep(1);
|
sleep(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"get template\n");
|
|
||||||
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
|
||||||
if (!pblocktemplate.get())
|
if (!pblocktemplate.get())
|
||||||
{
|
{
|
||||||
@@ -1784,7 +1730,6 @@ void static BitcoinMiner()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||||
//fprintf(stderr,"Running HushMiner.%s with %u transactions in block\n",solver.c_str(),(int32_t)pblock->vtx.size());
|
|
||||||
LogPrintf("Running HushMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
LogPrintf("Running HushMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
@@ -1800,7 +1745,6 @@ void static BitcoinMiner()
|
|||||||
gotinvalid = 0;
|
gotinvalid = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"gotinvalid.%d\n",gotinvalid);
|
|
||||||
if ( gotinvalid != 0 )
|
if ( gotinvalid != 0 )
|
||||||
break;
|
break;
|
||||||
hush_longestchain();
|
hush_longestchain();
|
||||||
@@ -1825,7 +1769,6 @@ void static BitcoinMiner()
|
|||||||
if ( HUSH_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 )
|
if ( HUSH_MININGTHREADS > 0 && ASSETCHAINS_STAKED > 0 && ASSETCHAINS_STAKED < 100 && Mining_height > 10 )
|
||||||
hashTarget = HASHTarget_POW;
|
hashTarget = HASHTarget_POW;
|
||||||
//else if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
|
//else if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
|
||||||
// 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 =
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
@@ -1839,7 +1782,6 @@ void static BitcoinMiner()
|
|||||||
LogPrint("pow", "- Checking solution against target\n");
|
LogPrint("pow", "- Checking solution against target\n");
|
||||||
pblock->nSolution = soln;
|
pblock->nSolution = soln;
|
||||||
solutionTargetChecks.increment();
|
solutionTargetChecks.increment();
|
||||||
// fprintf(stderr, "%s: solutionTargetChecks=%lu\n", __func__, solutionTargetChecks.get());
|
|
||||||
B = *pblock;
|
B = *pblock;
|
||||||
h = UintToArith256(B.GetHash());
|
h = UintToArith256(B.GetHash());
|
||||||
/*for (z=31; z>=16; z--)
|
/*for (z=31; z>=16; z--)
|
||||||
@@ -1859,7 +1801,6 @@ void static BitcoinMiner()
|
|||||||
}
|
}
|
||||||
if ( IS_HUSH_NOTARY != 0 && B.nTime > GetTime() )
|
if ( IS_HUSH_NOTARY != 0 && B.nTime > GetTime() )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetTime()));
|
|
||||||
while ( GetTime() < B.nTime-2 )
|
while ( GetTime() < B.nTime-2 )
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@@ -1893,8 +1834,6 @@ void static BitcoinMiner()
|
|||||||
{
|
{
|
||||||
h = UintToArith256(B.GetHash());
|
h = UintToArith256(B.GetHash());
|
||||||
//for (z=31; z>=0; z--)
|
//for (z=31; z>=0; z--)
|
||||||
// fprintf(stderr,"%02x",((uint8_t *)&h)[z]);
|
|
||||||
//fprintf(stderr," Invalid block mined, try again\n");
|
|
||||||
gotinvalid = 1;
|
gotinvalid = 1;
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@@ -1969,8 +1908,6 @@ void static BitcoinMiner()
|
|||||||
if (found) {
|
if (found) {
|
||||||
int32_t i; uint256 hash = pblock->GetHash();
|
int32_t i; uint256 hash = pblock->GetHash();
|
||||||
//for (i=0; i<32; i++)
|
//for (i=0; i<32; i++)
|
||||||
// fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
|
|
||||||
//fprintf(stderr," <- %s Block found %d\n",SMART_CHAIN_SYMBOL,Mining_height);
|
|
||||||
//FOUND_BLOCK = 1;
|
//FOUND_BLOCK = 1;
|
||||||
//HUSH_MAYBEMINED = Mining_height;
|
//HUSH_MAYBEMINED = Mining_height;
|
||||||
break;
|
break;
|
||||||
@@ -2026,7 +1963,6 @@ void static BitcoinMiner()
|
|||||||
HASHTarget.SetCompact(pblock->nBits);
|
HASHTarget.SetCompact(pblock->nBits);
|
||||||
hashTarget = HASHTarget;
|
hashTarget = HASHTarget;
|
||||||
savebits = pblock->nBits;
|
savebits = pblock->nBits;
|
||||||
//hashTarget = HASHTarget_POW = hush_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime);
|
|
||||||
}
|
}
|
||||||
/*if ( NOTARY_PUBKEY33[0] == 0 )
|
/*if ( NOTARY_PUBKEY33[0] == 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -325,14 +325,12 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
CScript scriptPubKey;
|
CScript scriptPubKey;
|
||||||
for (auto t : t_inputs_) {
|
for (auto t : t_inputs_) {
|
||||||
scriptPubKey = GetScriptForDestination(std::get<4>(t));
|
scriptPubKey = GetScriptForDestination(std::get<4>(t));
|
||||||
//printf("Checking new script: %s\n", scriptPubKey.ToString().c_str());
|
|
||||||
uint256 txid = std::get<0>(t);
|
uint256 txid = std::get<0>(t);
|
||||||
int vout = std::get<1>(t);
|
int vout = std::get<1>(t);
|
||||||
CAmount amount = std::get<2>(t);
|
CAmount amount = std::get<2>(t);
|
||||||
builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount);
|
builder_.AddTransparentInput(COutPoint(txid, vout), scriptPubKey, amount);
|
||||||
}
|
}
|
||||||
// for other chains, set locktime to spend time locked coinbases
|
// for other chains, set locktime to spend time locked coinbases
|
||||||
//builder_.SetLockTime((uint32_t)chainActive.Tip()->GetMedianTimePast());
|
|
||||||
} else {
|
} else {
|
||||||
CMutableTransaction rawTx(tx_);
|
CMutableTransaction rawTx(tx_);
|
||||||
for (SendManyInputUTXO & t : t_inputs_) {
|
for (SendManyInputUTXO & t : t_inputs_) {
|
||||||
@@ -342,7 +340,6 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
CTxIn in(COutPoint(txid, vout));
|
CTxIn in(COutPoint(txid, vout));
|
||||||
rawTx.vin.push_back(in);
|
rawTx.vin.push_back(in);
|
||||||
}
|
}
|
||||||
//rawTx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast();
|
|
||||||
tx_ = CTransaction(rawTx);
|
tx_ = CTransaction(rawTx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -416,7 +413,6 @@ bool AsyncRPCOperation_sendmany::main_impl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fetch Sapling anchor and witnesses
|
// Fetch Sapling anchor and witnesses
|
||||||
//LogPrintf("%s: Gathering anchors and witnesses\n", __FUNCTION__);
|
|
||||||
uint256 anchor;
|
uint256 anchor;
|
||||||
std::vector<boost::optional<SaplingWitness>> witnesses;
|
std::vector<boost::optional<SaplingWitness>> witnesses;
|
||||||
{
|
{
|
||||||
@@ -625,7 +621,6 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("%s\n", boost::apply_visitor(AddressVisitorString(), dest).c_str());
|
|
||||||
if (!destinations.count(dest)) {
|
if (!destinations.count(dest)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user