yep
This commit is contained in:
73
src/init.cpp
73
src/init.cpp
@@ -207,6 +207,7 @@ void Interrupt(boost::thread_group& threadGroup)
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
fprintf(stderr,"%s: start\n", __FUNCTION__);
|
||||
LogPrintf("%s: In progress...\n", __func__);
|
||||
static CCriticalSection cs_Shutdown;
|
||||
TRY_LOCK(cs_Shutdown, lockShutdown);
|
||||
@@ -218,10 +219,11 @@ void Shutdown()
|
||||
/// Be sure that anything that writes files or flushes caches only does this if the respective
|
||||
/// module was initialized.
|
||||
static char shutoffstr[128];
|
||||
sprintf(shutoffstr,"%s-shutoff",ASSETCHAINS_SYMBOL);
|
||||
sprintf(shutoffstr,"%s-shutoff","hush");
|
||||
RenameThread(shutoffstr);
|
||||
mempool.AddTransactionsUpdated(1);
|
||||
|
||||
fprintf(stderr,"%s: stopping HTTP/REST/RPC\n", __FUNCTION__);
|
||||
StopHTTPRPC();
|
||||
StopREST();
|
||||
StopRPC();
|
||||
@@ -237,6 +239,7 @@ void Shutdown()
|
||||
GenerateBitcoins(false, 0);
|
||||
#endif
|
||||
#endif
|
||||
fprintf(stderr,"%s: stopping node\n", __FUNCTION__);
|
||||
StopNode();
|
||||
StopTorControl();
|
||||
UnregisterNodeSignals(GetNodeSignals());
|
||||
@@ -747,17 +750,20 @@ void ThreadNotifyRecentlyAdded()
|
||||
}
|
||||
|
||||
/** Sanity checks
|
||||
* Ensure that Bitcoin is running in a usable environment with all
|
||||
* Ensure that Hush is running in a usable environment with all
|
||||
* necessary library support.
|
||||
*/
|
||||
bool InitSanityCheck(void)
|
||||
{
|
||||
if(!ECC_InitSanityCheck()) {
|
||||
InitError("Elliptic curve cryptography sanity check failure. Aborting.");
|
||||
fprintf(stderr,"%s: ECC insanity!\n", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
if (!glibc_sanity_test() || !glibcxx_sanity_test())
|
||||
if (!glibc_sanity_test() || !glibcxx_sanity_test()) {
|
||||
fprintf(stderr,"%s: glibc insanity!\n", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -894,6 +900,7 @@ extern int32_t KOMODO_REWIND;
|
||||
|
||||
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
{
|
||||
fprintf(stderr,"%s start\n", __FUNCTION__);
|
||||
// ********************************************************* Step 1: setup
|
||||
#ifdef _MSC_VER
|
||||
// Turn off Microsoft heap dump noise
|
||||
@@ -920,6 +927,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
if (!SetupNetworking())
|
||||
return InitError("Error: Initializing networking failed");
|
||||
fprintf(stderr,"%s networking setup\n", __FUNCTION__);
|
||||
|
||||
#ifndef _WIN32
|
||||
if (GetBoolArg("-sysperms", false)) {
|
||||
@@ -928,9 +936,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
return InitError("Error: -sysperms is not allowed in combination with enabled wallet functionality");
|
||||
#endif
|
||||
} else {
|
||||
fprintf(stderr,"%s setting umask\n", __FUNCTION__);
|
||||
umask(077);
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s tik1\n", __FUNCTION__);
|
||||
// Clean shutdown on SIGTERM
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = HandleSIGTERM;
|
||||
@@ -952,31 +962,42 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
std::set_new_handler(new_handler_terminate);
|
||||
|
||||
fprintf(stderr,"%s: set signal handlers\n", __FUNCTION__);
|
||||
|
||||
// ********************************************************* Step 2: parameter interactions
|
||||
const CChainParams& chainparams = Params();
|
||||
|
||||
fprintf(stderr,"%s: got chain params\n", __FUNCTION__);
|
||||
|
||||
// Set this early so that experimental features are correctly enabled/disabled
|
||||
fExperimentalMode = GetBoolArg("-experimentalfeatures", true);
|
||||
|
||||
fprintf(stderr,"%s: fExperimentalMode=%d\n", __FUNCTION__, fExperimentalMode);
|
||||
|
||||
// Fail early if user has set experimental options without the global flag
|
||||
if (!fExperimentalMode) {
|
||||
if (mapArgs.count("-developerencryptwallet")) {
|
||||
fprintf(stderr,"%s wallet encryption error\n", __FUNCTION__);
|
||||
return InitError(_("Wallet encryption requires -experimentalfeatures."));
|
||||
}
|
||||
else if (mapArgs.count("-paymentdisclosure")) {
|
||||
fprintf(stderr,"%s payment disclosure error\n", __FUNCTION__);
|
||||
return InitError(_("Payment disclosure requires -experimentalfeatures."));
|
||||
} else if (mapArgs.count("-zmergetoaddress")) {
|
||||
fprintf(stderr,"%s zmerge error\n", __FUNCTION__);
|
||||
return InitError(_("RPC method z_mergetoaddress requires -experimentalfeatures."));
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"%s tik2\n", __FUNCTION__);
|
||||
|
||||
// Set this early so that parameter interactions go to console
|
||||
fPrintToConsole = GetBoolArg("-printtoconsole", false);
|
||||
fLogTimestamps = GetBoolArg("-logtimestamps", true);
|
||||
fLogIPs = GetBoolArg("-logips", false);
|
||||
fLogTimestamps = GetBoolArg("-logtimestamps", true);
|
||||
fLogIPs = GetBoolArg("-logips", false);
|
||||
|
||||
|
||||
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
LogPrintf("Zcash version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
|
||||
LogPrintf("Hush version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
|
||||
|
||||
// when specifying an explicit binding address, you want to listen on it
|
||||
// even when -connect or -proxy is specified
|
||||
@@ -989,6 +1010,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s tik3\n", __FUNCTION__);
|
||||
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) {
|
||||
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
||||
if (SoftSetBoolArg("-dnsseed", false))
|
||||
@@ -1031,6 +1053,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (SoftSetBoolArg("-rescan", true))
|
||||
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
|
||||
}
|
||||
fprintf(stderr,"%s tik4\n", __FUNCTION__);
|
||||
|
||||
// Make sure enough file descriptors are available
|
||||
int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-whitebind"), 1);
|
||||
@@ -1038,7 +1061,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
//fprintf(stderr,"nMaxConnections %d\n",nMaxConnections);
|
||||
nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0);
|
||||
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));
|
||||
if (nFD < MIN_CORE_FILEDESCRIPTORS)
|
||||
return InitError(_("Not enough file descriptors available."));
|
||||
if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections)
|
||||
@@ -1076,6 +1099,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s tik5\n", __FUNCTION__);
|
||||
// Check for -debugnet
|
||||
if (GetBoolArg("-debugnet", false))
|
||||
InitWarning(_("Warning: Unsupported argument -debugnet ignored, use -debug=net."));
|
||||
@@ -1107,6 +1131,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS;
|
||||
|
||||
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
|
||||
int64_t nSignedPruneTarget = GetArg("-prune", 0) * 1024 * 1024;
|
||||
@@ -1194,6 +1219,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
expiryDelta = GetArg("-txexpirydelta", DEFAULT_TX_EXPIRY_DELTA);
|
||||
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", true);
|
||||
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", false);
|
||||
fprintf(stderr,"%s tik7\n", __FUNCTION__);
|
||||
|
||||
std::string strWalletFile = GetArg("-wallet", "wallet.dat");
|
||||
#endif // ENABLE_WALLET
|
||||
@@ -1212,6 +1238,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
nLocalServices |= NODE_BLOOM;
|
||||
}
|
||||
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
|
||||
fprintf(stderr,"%s tik8\n", __FUNCTION__);
|
||||
|
||||
#ifdef ENABLE_MINING
|
||||
if (mapArgs.count("-mineraddress")) {
|
||||
@@ -1234,6 +1261,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s tik9\n", __FUNCTION__);
|
||||
if (!mapMultiArgs["-nuparams"].empty()) {
|
||||
// Allow overriding network upgrade parameters for testing
|
||||
if (Params().NetworkIDString() != "regtest") {
|
||||
@@ -1271,6 +1299,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
// Initialize libsodium
|
||||
if (init_and_check_sodium() == -1) {
|
||||
fprintf(stderr,"%s: libsodium init failed!\n", __FUNCTION__);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1278,6 +1307,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
ECC_Start();
|
||||
globalVerifyHandle.reset(new ECCVerifyHandle());
|
||||
|
||||
/*
|
||||
// set the hash algorithm to use for this chain
|
||||
// Again likely better solution here, than using long IF ELSE.
|
||||
extern uint32_t ASSETCHAINS_ALGO, ASSETCHAINS_VERUSHASH, ASSETCHAINS_VERUSHASHV1_1;
|
||||
@@ -1293,7 +1323,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
// initialize VerusHashV2
|
||||
CBlockHeader::SetVerusHashV2();
|
||||
}
|
||||
*/
|
||||
|
||||
fprintf(stderr,"%s tik10\n", __FUNCTION__);
|
||||
// Sanity check
|
||||
if (!InitSanityCheck())
|
||||
return InitError(_("Initialization sanity check failed. Please check for insanity. Hush is shutting down!"));
|
||||
@@ -1310,6 +1342,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (file) fclose(file);
|
||||
|
||||
|
||||
fprintf(stderr,"%s tik11\n", __FUNCTION__);
|
||||
fprintf(stderr,"Attempting to obtain lock %s\n", pathLockFile.string().c_str());
|
||||
try {
|
||||
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
|
||||
@@ -1324,6 +1357,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
#endif
|
||||
if (GetBoolArg("-shrinkdebugfile", !fDebug))
|
||||
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("Hush version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
|
||||
|
||||
@@ -1347,12 +1383,15 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
threadGroup.create_thread(&ThreadScriptCheck);
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s tik13\n", __FUNCTION__);
|
||||
|
||||
// Start the lightweight task scheduler thread
|
||||
CScheduler::Function serviceLoop = boost::bind(&CScheduler::serviceQueue, &scheduler);
|
||||
threadGroup.create_thread(boost::bind(&TraceThread<CScheduler::Function>, "scheduler", serviceLoop));
|
||||
|
||||
// Count uptime
|
||||
MarkStartTime();
|
||||
fprintf(stderr,"%s tik14\n", __FUNCTION__);
|
||||
|
||||
if ((chainparams.NetworkIDString() != "regtest") &&
|
||||
GetBoolArg("-showmetrics", 0) &&
|
||||
@@ -1362,6 +1401,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
threadGroup.create_thread(&ThreadShowMetricsScreen);
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s tik15\n", __FUNCTION__);
|
||||
// These must be disabled for now, they are buggy and we probably don't
|
||||
// want any of libsnark's profiling in production anyway.
|
||||
libsnark::inhibit_profiling_info = true;
|
||||
@@ -1383,6 +1423,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (!AppInitServers(threadGroup))
|
||||
return InitError(_("Unable to start HTTP server. See debug log for details."));
|
||||
}
|
||||
fprintf(stderr,"%s tik16\n", __FUNCTION__);
|
||||
|
||||
int64_t nStart;
|
||||
|
||||
@@ -1407,6 +1448,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
#endif // ENABLE_WALLET
|
||||
// ********************************************************* Step 6: network initialization
|
||||
|
||||
fprintf(stderr,"%s tik17\n", __FUNCTION__);
|
||||
RegisterNodeSignals(GetNodeSignals());
|
||||
|
||||
// sanitize comments per BIP-0014, format user agent and check total size
|
||||
@@ -1422,6 +1464,7 @@ 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.",
|
||||
strSubVersion.size(), MAX_SUBVERSION_LENGTH));
|
||||
}
|
||||
fprintf(stderr,"%s tik18\n", __FUNCTION__);
|
||||
|
||||
if (mapArgs.count("-onlynet")) {
|
||||
std::set<enum Network> nets;
|
||||
@@ -1438,6 +1481,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s tik19\n", __FUNCTION__);
|
||||
if (mapArgs.count("-whitelist")) {
|
||||
BOOST_FOREACH(const std::string& net, mapMultiArgs["-whitelist"]) {
|
||||
CSubNet subnet(net);
|
||||
@@ -1463,6 +1507,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
SetNameProxy(addrProxy);
|
||||
SetLimited(NET_TOR, false); // by default, -proxy sets onion as reachable, unless -noonion later
|
||||
}
|
||||
fprintf(stderr,"%s tik20\n", __FUNCTION__);
|
||||
|
||||
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
|
||||
// -noonion (or -onion=0) disables connecting to .onion entirely
|
||||
@@ -1481,10 +1526,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
|
||||
// see Step 2: parameter interactions for more information about these
|
||||
fListen = GetBoolArg("-listen", DEFAULT_LISTEN);
|
||||
fDiscover = GetBoolArg("-discover", true);
|
||||
fListen = GetBoolArg("-listen", DEFAULT_LISTEN);
|
||||
fDiscover = GetBoolArg("-discover", true);
|
||||
fNameLookup = GetBoolArg("-dns", true);
|
||||
|
||||
fprintf(stderr,"%s tik22\n", __FUNCTION__);
|
||||
bool fBound = false;
|
||||
if (fListen) {
|
||||
if (mapArgs.count("-bind") || mapArgs.count("-whitebind")) {
|
||||
@@ -1522,6 +1568,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,"%s tik23\n", __FUNCTION__);
|
||||
|
||||
BOOST_FOREACH(const std::string& strDest, mapMultiArgs["-seednode"])
|
||||
AddOneShot(strDest);
|
||||
|
||||
@@ -1561,6 +1609,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
return !fRequestShutdown;
|
||||
}
|
||||
// ********************************************************* Step 7: load block chain
|
||||
fprintf(stderr,"%s tik24\n", __FUNCTION__);
|
||||
|
||||
fReindex = GetBoolArg("-reindex", false);
|
||||
|
||||
@@ -1791,6 +1840,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
mempool.ReadFeeEstimates(est_filein);
|
||||
fFeeEstimatesInitialized = true;
|
||||
|
||||
fprintf(stderr,"%s tik25\n", __FUNCTION__);
|
||||
|
||||
// ********************************************************* Step 8: load wallet
|
||||
#ifdef ENABLE_WALLET
|
||||
@@ -2063,9 +2113,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
if (pwalletMain) {
|
||||
fprintf(stderr,"%s reaccepting wallet xtns\n", __FUNCTION__);
|
||||
// Add wallet transactions that aren't already in a block to mapTransactions
|
||||
pwalletMain->ReacceptWalletTransactions();
|
||||
|
||||
fprintf(stderr,"%s starting wallet flusher thread\n", __FUNCTION__);
|
||||
// Run a thread to flush wallet periodically
|
||||
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
|
||||
}
|
||||
@@ -2074,5 +2126,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
// SENDALERT
|
||||
threadGroup.create_thread(boost::bind(ThreadSendAlert));
|
||||
|
||||
fprintf(stderr,"%s end\n", __FUNCTION__);
|
||||
return !fRequestShutdown;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user