Fix lots of little things that were undone by migrating Hush to KMD source code

This commit is contained in:
Duke Leto
2019-10-25 10:17:30 -04:00
parent 3a7db19af4
commit b00cda1c09
10 changed files with 59 additions and 35 deletions

View File

@@ -42,13 +42,13 @@ details of their operating practices.
related to the DNS seed operation. related to the DNS seed operation.
If these expectations cannot be satisfied the operator should discontinue If these expectations cannot be satisfied the operator should discontinue
providing services and contact the active Zcash development team as well as providing services and contact the active Hush development team as well as
creating an issue in the [Zcash repository](https://github.com/zcash/zcash). creating an issue in the [Hush Github repository](https://github.com/MyHush/hush3).
Behavior outside of these expectations may be reasonable in some Behavior outside of these expectations may be reasonable in some
situations but should be discussed in public in advance. situations but should be discussed in public in advance.
See also See also
---------- ----------
- [zcash-seeder](https://github.com/zcash/zcash-seeder) is a reference - [hush-seeder](https://github.com/MyHush/hush-seeder) is a reference
implementation of a DNS seed. implementation of a DNS seed.

View File

@@ -16,14 +16,14 @@ BEGIN
BEGIN BEGIN
BLOCK "040904E4" // U.S. English - multilingual (hex) BLOCK "040904E4" // U.S. English - multilingual (hex)
BEGIN BEGIN
VALUE "CompanyName", "Zcash" VALUE "CompanyName", "Hush"
VALUE "FileDescription", "zcash-tx (CLI Zcash transaction editor utility)" VALUE "FileDescription", "hush-tx (CLI Zcash transaction editor utility)"
VALUE "FileVersion", VER_FILEVERSION_STR VALUE "FileVersion", VER_FILEVERSION_STR
VALUE "InternalName", "zcash-tx" VALUE "InternalName", "hush-tx"
VALUE "LegalCopyright", COPYRIGHT_STR VALUE "LegalCopyright", COPYRIGHT_STR
VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php."
VALUE "OriginalFilename", "zcash-tx.exe" VALUE "OriginalFilename", "hush-tx.exe"
VALUE "ProductName", "zcash-tx" VALUE "ProductName", "hush-tx"
VALUE "ProductVersion", VER_PRODUCTVERSION_STR VALUE "ProductVersion", VER_PRODUCTVERSION_STR
END END
END END

View File

@@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2009-2013 The Bitcoin Core developers
// Copyright (c) 2019 The Hush developers
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -70,12 +71,17 @@ CBlockIndex *komodo_chainactive(int32_t height);
void WaitForShutdown(boost::thread_group* threadGroup) void WaitForShutdown(boost::thread_group* threadGroup)
{ {
int32_t i,height; CBlockIndex *pindex; bool fShutdown = ShutdownRequested(); const uint256 zeroid; int32_t i,height; CBlockIndex *pindex; bool fShutdown = ShutdownRequested(); const uint256 zeroid;
fprintf(stderr,"%s: fShutdown=%d, KOMODO_EARLYTXID_HEIGHT=%d\n", __FUNCTION__, fShutdown, KOMODO_EARLYTXID_HEIGHT);
// Tell the main threads to shutdown. // Tell the main threads to shutdown.
if (komodo_currentheight()>KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID!=zeroid && ((height=tx_height(KOMODO_EARLYTXID))==0 || height>KOMODO_EARLYTXID_HEIGHT)) if (komodo_currentheight()>KOMODO_EARLYTXID_HEIGHT && KOMODO_EARLYTXID!=zeroid && ((height=tx_height(KOMODO_EARLYTXID))==0 || height>KOMODO_EARLYTXID_HEIGHT))
{ {
fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT); fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown(); StartShutdown();
} }
fprintf(stderr,"%s: earlytx height=%d, ASSETCHAINS_CBOPRET=%li\n", __FUNCTION__, height, ASSETCHAINS_CBOPRET);
/*if ( ASSETCHAINS_STAKED == 0 && ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_chainactive(1)) != 0 ) /*if ( ASSETCHAINS_STAKED == 0 && ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_chainactive(1)) != 0 )
{ {
if ( pindex->nTime > ADAPTIVEPOW_CHANGETO_DEFAULTON ) if ( pindex->nTime > ADAPTIVEPOW_CHANGETO_DEFAULTON )
@@ -84,11 +90,14 @@ void WaitForShutdown(boost::thread_group* threadGroup)
fprintf(stderr,"default activate adaptivepow\n"); fprintf(stderr,"default activate adaptivepow\n");
} else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON); } else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON);
} //else fprintf(stderr,"cant find height 1\n");*/ } //else fprintf(stderr,"cant find height 1\n");*/
if ( ASSETCHAINS_CBOPRET != 0 )
if ( ASSETCHAINS_CBOPRET != 0 ) {
komodo_pricesinit(); komodo_pricesinit();
}
while (!fShutdown) while (!fShutdown)
{ {
//fprintf(stderr,"call passport iteration\n"); fprintf(stderr,"call passport iteration\n");
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
{ {
if ( KOMODO_NSPV_FULLNODE ) if ( KOMODO_NSPV_FULLNODE )
@@ -100,9 +109,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
break; break;
MilliSleep(1000); MilliSleep(1000);
} }
} } else {
else
{
//komodo_interestsum(); //komodo_interestsum();
//komodo_longestchain(); //komodo_longestchain();
if ( ASSETCHAINS_CBOPRET != 0 ) if ( ASSETCHAINS_CBOPRET != 0 )
@@ -117,6 +124,8 @@ void WaitForShutdown(boost::thread_group* threadGroup)
} }
fShutdown = ShutdownRequested(); fShutdown = ShutdownRequested();
} }
fprintf(stderr,"%s: fShutdown=%d\n", __FUNCTION__, fShutdown);
if (threadGroup) if (threadGroup)
{ {
Interrupt(*threadGroup); Interrupt(*threadGroup);
@@ -141,6 +150,8 @@ bool AppInit(int argc, char* argv[])
bool fRet = false; bool fRet = false;
fprintf(stderr, "%s start, argc=%d\n", __FUNCTION__, argc);
// //
// Parameters // Parameters
// //
@@ -189,6 +200,7 @@ bool AppInit(int argc, char* argv[])
} }
try try
{ {
fprintf(stderr, "%s reading config file\n", __FUNCTION__);
ReadConfigFile(mapArgs, mapMultiArgs); ReadConfigFile(mapArgs, mapMultiArgs);
} catch (const missing_zcash_conf& e) { } catch (const missing_zcash_conf& e) {
fprintf(stderr, fprintf(stderr,
@@ -216,9 +228,12 @@ bool AppInit(int argc, char* argv[])
// Command-line RPC // Command-line RPC
bool fCommandLine = false; bool fCommandLine = false;
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++) {
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "komodo:")) //TODO: should this be hush: or komodo: ??
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "komodo:")) {
fCommandLine = true; fCommandLine = true;
}
}
if (fCommandLine) if (fCommandLine)
{ {
@@ -252,20 +267,23 @@ bool AppInit(int argc, char* argv[])
#endif #endif
SoftSetBoolArg("-server", true); SoftSetBoolArg("-server", true);
fprintf(stderr,"%s: Running AppInit2()\n", __FUNCTION__);
fRet = AppInit2(threadGroup, scheduler); fRet = AppInit2(threadGroup, scheduler);
} fprintf(stderr,"%s: Finished AppInit2(), fRet=%d\n", __FUNCTION__, fRet);
catch (const std::exception& e) { } catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInit()"); PrintExceptionContinue(&e, "AppInit()");
} catch (...) { } catch (...) {
PrintExceptionContinue(NULL, "AppInit()"); PrintExceptionContinue(NULL, "AppInit()");
} }
if (!fRet) if (!fRet)
{ {
fprintf(stderr,"%s: Interrupting threadGroup\n", __FUNCTION__);
Interrupt(threadGroup); Interrupt(threadGroup);
// threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of // threadGroup.join_all(); was left out intentionally here, because we didn't re-test all of
// the startup-failure cases to make sure they don't result in a hang due to some // the startup-failure cases to make sure they don't result in a hang due to some
// thread-blocking-waiting-for-another-thread-during-startup case // thread-blocking-waiting-for-another-thread-during-startup case
} else { } else {
fprintf(stderr,"%s: Waiting for Shutdown\n", __FUNCTION__);
WaitForShutdown(&threadGroup); WaitForShutdown(&threadGroup);
} }
Shutdown(); Shutdown();

View File

@@ -306,7 +306,7 @@ static void http_reject_request_cb(struct evhttp_request* req, void*)
/** Event dispatcher thread */ /** Event dispatcher thread */
static void ThreadHTTP(struct event_base* base, struct evhttp* http) static void ThreadHTTP(struct event_base* base, struct evhttp* http)
{ {
RenameThread("zcash-http"); RenameThread("hush-http");
LogPrint("http", "Entering http event loop\n"); LogPrint("http", "Entering http event loop\n");
event_base_dispatch(base); event_base_dispatch(base);
// Event loop will be interrupted by InterruptHTTPServer() // Event loop will be interrupted by InterruptHTTPServer()
@@ -355,7 +355,7 @@ static bool HTTPBindAddresses(struct evhttp* http)
/** Simple wrapper to set thread name and run work queue */ /** Simple wrapper to set thread name and run work queue */
static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue) static void HTTPWorkQueueRun(WorkQueue<HTTPClosure>* queue)
{ {
RenameThread("zcash-httpworker"); RenameThread("hush-httpworker");
queue->Run(); queue->Run();
} }

View File

@@ -219,7 +219,6 @@ void Shutdown()
/// module was initialized. /// module was initialized.
static char shutoffstr[128]; static char shutoffstr[128];
sprintf(shutoffstr,"%s-shutoff",ASSETCHAINS_SYMBOL); sprintf(shutoffstr,"%s-shutoff",ASSETCHAINS_SYMBOL);
//RenameThread("verus-shutoff");
RenameThread(shutoffstr); RenameThread(shutoffstr);
mempool.AddTransactionsUpdated(1); mempool.AddTransactionsUpdated(1);
@@ -674,7 +673,7 @@ void CleanupBlockRevFiles()
void ThreadImport(std::vector<boost::filesystem::path> vImportFiles) void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
{ {
RenameThread("zcash-loadblk"); RenameThread("hush-loadblk");
// -reindex // -reindex
if (fReindex) { if (fReindex) {
CImportingNow imp; CImportingNow imp;

View File

@@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2019 The Hush developers
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -3352,7 +3353,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
static CCheckQueue<CScriptCheck> scriptcheckqueue(128); static CCheckQueue<CScriptCheck> scriptcheckqueue(128);
void ThreadScriptCheck() { void ThreadScriptCheck() {
RenameThread("zcash-scriptch"); RenameThread("hush-scriptch");
scriptcheckqueue.Thread(); scriptcheckqueue.Thread();
} }
@@ -4260,6 +4261,7 @@ static int64_t nTimePostConnect = 0;
*/ */
bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) { bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *pblock) {
fprintf(stderr, "%s: Start\n", __FUNCTION__);
assert(pindexNew->pprev == chainActive.Tip()); assert(pindexNew->pprev == chainActive.Tip());
// Read block from disk. // Read block from disk.
int64_t nTime1 = GetTimeMicros(); int64_t nTime1 = GetTimeMicros();
@@ -4270,7 +4272,8 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
pblock = &block; pblock = &block;
} }
KOMODO_CONNECTING = (int32_t)pindexNew->GetHeight(); KOMODO_CONNECTING = (int32_t)pindexNew->GetHeight();
//fprintf(stderr,"%s connecting ht.%d maxsize.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pindexNew->GetHeight(),MAX_BLOCK_SIZE(pindexNew->GetHeight()),(int32_t)::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); fprintf(stderr,"%s connecting ht.%d maxsize.%d vs %d\n",ASSETCHAINS_SYMBOL,(int32_t)pindexNew->GetHeight(),MAX_BLOCK_SIZE(pindexNew->GetHeight()),(int32_t)::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
// Get the current commitment tree // Get the current commitment tree
SproutMerkleTree oldSproutTree; SproutMerkleTree oldSproutTree;
SaplingMerkleTree oldSaplingTree; SaplingMerkleTree oldSaplingTree;
@@ -4348,7 +4351,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
if ( KOMODO_LONGESTCHAIN != 0 && (pindexNew->GetHeight() == KOMODO_LONGESTCHAIN || pindexNew->GetHeight() == KOMODO_LONGESTCHAIN+1) ) if ( KOMODO_LONGESTCHAIN != 0 && (pindexNew->GetHeight() == KOMODO_LONGESTCHAIN || pindexNew->GetHeight() == KOMODO_LONGESTCHAIN+1) )
KOMODO_INSYNC = (int32_t)pindexNew->GetHeight(); KOMODO_INSYNC = (int32_t)pindexNew->GetHeight();
else KOMODO_INSYNC = 0; else KOMODO_INSYNC = 0;
//fprintf(stderr,"connect.%d insync.%d ASSETCHAINS_SAPLING.%d\n",(int32_t)pindexNew->GetHeight(),KOMODO_INSYNC,ASSETCHAINS_SAPLING); fprintf(stderr,"connect.%d insync.%d ASSETCHAINS_SAPLING.%d\n",(int32_t)pindexNew->GetHeight(),KOMODO_INSYNC,ASSETCHAINS_SAPLING);
/*if ( KOMODO_INSYNC != 0 ) //ASSETCHAINS_SYMBOL[0] == 0 && /*if ( KOMODO_INSYNC != 0 ) //ASSETCHAINS_SYMBOL[0] == 0 &&
komodo_broadcast(pblock,8); komodo_broadcast(pblock,8);
else if ( ASSETCHAINS_SYMBOL[0] != 0 ) else if ( ASSETCHAINS_SYMBOL[0] != 0 )
@@ -4448,6 +4451,7 @@ static void PruneBlockIndexCandidates() {
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork. * pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
*/ */
static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) { static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) {
fprintf(stderr,"%s: fSkipdpow=%d\n", __FUNCTION__, fSkipdpow);
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
bool fInvalidFound = false; bool fInvalidFound = false;
const CBlockIndex *pindexOldTip = chainActive.Tip(); const CBlockIndex *pindexOldTip = chainActive.Tip();
@@ -4583,6 +4587,7 @@ static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBloc
* that is already loaded (to avoid loading it again from disk). * that is already loaded (to avoid loading it again from disk).
*/ */
bool ActivateBestChain(bool fSkipdpow, CValidationState &state, CBlock *pblock) { bool ActivateBestChain(bool fSkipdpow, CValidationState &state, CBlock *pblock) {
fprintf(stderr,"%s: fSkipdpow=%d\n", __FUNCTION__, fSkipdpow);
CBlockIndex *pindexNewTip = NULL; CBlockIndex *pindexNewTip = NULL;
CBlockIndex *pindexMostWork = NULL; CBlockIndex *pindexMostWork = NULL;
const CChainParams& chainParams = Params(); const CChainParams& chainParams = Params();

View File

@@ -1,4 +1,5 @@
// Copyright (c) 2016 The Zcash developers // Copyright (c) 2016 The Zcash developers
// Copyright (c) 2019 The Hush developers
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -298,7 +299,7 @@ int printMiningStatus(bool mining)
lines++; lines++;
} else { } else {
std::cout << _("You are currently not mining.") << std::endl; std::cout << _("You are currently not mining.") << std::endl;
std::cout << _("To enable mining, add 'gen=1' to your zcash.conf and restart.") << std::endl; std::cout << _("To enable mining, add 'gen=1' to your HUSH3.conf and restart.") << std::endl;
lines += 2; lines += 2;
} }
std::cout << std::endl; std::cout << std::endl;
@@ -479,7 +480,7 @@ bool enableVTMode()
void ThreadShowMetricsScreen() void ThreadShowMetricsScreen()
{ {
// Make this thread recognisable as the metrics screen thread // Make this thread recognisable as the metrics screen thread
RenameThread("zcash-metrics-screen"); RenameThread("hush-metrics-screen");
// Determine whether we should render a persistent UI or rolling metrics // Determine whether we should render a persistent UI or rolling metrics
bool isTTY = isatty(STDOUT_FILENO); bool isTTY = isatty(STDOUT_FILENO);
@@ -499,8 +500,8 @@ void ThreadShowMetricsScreen()
std::cout << std::endl; std::cout << std::endl;
// Thank you text // Thank you text
std::cout << _("Thank you for running a Zcash node!") << std::endl; std::cout << _("Thank you for running a Hush node!") << std::endl;
std::cout << _("You're helping to strengthen the network and contributing to a social good :)") << std::endl; std::cout << _("You are helping secure the network and others Speak And Transact Freely!") << std::endl;
// Privacy notice text // Privacy notice text
std::cout << PrivacyInfo(); std::cout << PrivacyInfo();
@@ -552,7 +553,7 @@ void ThreadShowMetricsScreen()
// Explain how to exit // Explain how to exit
std::cout << "["; std::cout << "[";
#ifdef WIN32 #ifdef WIN32
std::cout << _("'zcash-cli.exe stop' to exit"); std::cout << _("'hush-cli.exe stop' to exit");
#else #else
std::cout << _("Press Ctrl+C to exit"); std::cout << _("Press Ctrl+C to exit");
#endif #endif

View File

@@ -539,10 +539,10 @@ boost::filesystem::path GetDefaultDataDir()
if ( ASSETCHAINS_SYMBOL[0] != 0 ) if ( ASSETCHAINS_SYMBOL[0] != 0 )
strcpy(symbol,ASSETCHAINS_SYMBOL); strcpy(symbol,ASSETCHAINS_SYMBOL);
else symbol[0] = 0; else symbol[0] = 0;
// Windows < Vista: C:\Documents and Settings\Username\Application Data\Zcash // Windows < Vista: C:\Documents and Settings\Username\Application Data\Komodo
// Windows >= Vista: C:\Users\Username\AppData\Roaming\Zcash // Windows >= Vista: C:\Users\Username\AppData\Roaming\Komodo
// Mac: ~/Library/Application Support/Zcash // Mac: ~/Library/Application Support/Komodo
// Unix: ~/.zcash // Unix: ~/.komodo
#ifdef _WIN32 #ifdef _WIN32
// Windows // Windows
if ( symbol[0] == 0 ) if ( symbol[0] == 0 )
@@ -589,6 +589,7 @@ static boost::filesystem::path ZC_GetBaseParamsDir()
// Windows >= Vista: C:\Users\Username\AppData\Roaming\ZcashParams // Windows >= Vista: C:\Users\Username\AppData\Roaming\ZcashParams
// Mac: ~/Library/Application Support/ZcashParams // Mac: ~/Library/Application Support/ZcashParams
// Unix: ~/.zcash-params // Unix: ~/.zcash-params
// Debian packages: /usr/share/hush
fs::path pathRet; fs::path pathRet;
#ifdef _WIN32 #ifdef _WIN32
return GetSpecialFolderPath(CSIDL_APPDATA) / "ZcashParams"; return GetSpecialFolderPath(CSIDL_APPDATA) / "ZcashParams";

View File

@@ -264,7 +264,7 @@ void RenameThread(const char* name);
*/ */
template <typename Callable> void TraceThread(const char* name, Callable func) template <typename Callable> void TraceThread(const char* name, Callable func)
{ {
std::string s = strprintf("zcash-%s", name); std::string s = strprintf("hush-%s", name);
RenameThread(s.c_str()); RenameThread(s.c_str());
try try
{ {

View File

@@ -1115,7 +1115,7 @@ DBErrors CWalletDB::ZapWalletTx(CWallet* pwallet, vector<CWalletTx>& vWtx)
void ThreadFlushWalletDB(const string& strFile) void ThreadFlushWalletDB(const string& strFile)
{ {
// Make this thread recognisable as the wallet flushing thread // Make this thread recognisable as the wallet flushing thread
RenameThread("zcash-wallet"); RenameThread("hush-wallet");
static bool fOneThread; static bool fOneThread;
if (fOneThread) if (fOneThread)