Rename hush→dragonx across wallet codebase
- Rename RESOURCE_HUSHD/HUSH_CLI/HUSH_TX to RESOURCE_DRAGONXD/DRAGONX_CLI/DRAGONX_TX - Remove unused .bat resource constants (DRAGONXD_BAT, DRAGONX_CLI_BAT) - Update INCBIN symbols: g_hushd_exe → g_dragonxd_exe, etc. - Update daemon search paths, removing hush-arrakis-chain fallbacks - Update process detection (Windows findProcessByName, Linux /proc/comm, macOS pgrep) - Update build.sh: embed dragonxd.exe/dragonx-cli.exe/dragonx-tx.exe - Overhaul setup.sh: fix binary names, release paths, add -j passthrough - Update getDaemonPath/needsDaemonExtraction/hasDaemonAvailable for new names
This commit is contained in:
@@ -71,15 +71,10 @@ std::string EmbeddedDaemon::findDaemonBinary()
|
||||
#ifdef _WIN32
|
||||
// Check wallet's own directory for manually placed binaries
|
||||
std::vector<std::string> localPaths = {
|
||||
exe_dir + "\\hushd.exe",
|
||||
exe_dir + "\\hush-arrakis-chain.exe",
|
||||
exe_dir + "\\dragonxd.exe",
|
||||
exe_dir + "\\dragonxd.bat",
|
||||
};
|
||||
#else
|
||||
std::vector<std::string> localPaths = {
|
||||
exe_dir + "/hush-arrakis-chain",
|
||||
exe_dir + "/hushd",
|
||||
exe_dir + "/dragonxd",
|
||||
};
|
||||
#endif
|
||||
@@ -103,41 +98,36 @@ std::string EmbeddedDaemon::findDaemonBinary()
|
||||
// ---------------------------------------------------------------
|
||||
// 3. Search additional well-known locations
|
||||
// ---------------------------------------------------------------
|
||||
// IMPORTANT: Always prefer hushd.exe directly over dragonxd.bat
|
||||
// IMPORTANT: Always prefer dragonxd.exe directly over .bat wrappers.
|
||||
// Using .bat files causes issues because cmd.exe exits immediately
|
||||
// while hushd.exe continues running, making process monitoring fail.
|
||||
// while dragonxd.exe continues running, making process monitoring fail.
|
||||
std::vector<std::string> search_paths;
|
||||
|
||||
#ifdef _WIN32
|
||||
// Parent directory
|
||||
if (!exe_dir.empty()) {
|
||||
search_paths.push_back(exe_dir + "\\..\\hushd.exe");
|
||||
search_paths.push_back(exe_dir + "\\..\\dragonxd.bat");
|
||||
search_paths.push_back(exe_dir + "\\..\\dragonxd.exe");
|
||||
}
|
||||
search_paths.push_back("C:\\Program Files\\DragonX\\hushd.exe");
|
||||
search_paths.push_back("C:\\Program Files\\DragonX\\dragonxd.exe");
|
||||
#else
|
||||
if (!exe_dir.empty()) {
|
||||
search_paths.push_back(exe_dir + "/../hush-arrakis-chain");
|
||||
search_paths.push_back(exe_dir + "/../bin/hush-arrakis-chain");
|
||||
search_paths.push_back(exe_dir + "/../dragonxd");
|
||||
}
|
||||
|
||||
// Standard Linux locations
|
||||
search_paths.push_back("/usr/local/bin/hush-arrakis-chain");
|
||||
search_paths.push_back("/usr/bin/hush-arrakis-chain");
|
||||
search_paths.push_back("/usr/local/bin/dragonxd");
|
||||
search_paths.push_back("/usr/bin/dragonxd");
|
||||
|
||||
// Home directory
|
||||
const char* home = getenv("HOME");
|
||||
if (home) {
|
||||
search_paths.push_back(std::string(home) + "/hush3/src/hush-arrakis-chain");
|
||||
search_paths.push_back(std::string(home) + "/hush3/src/dragonxd");
|
||||
search_paths.push_back(std::string(home) + "/bin/hush-arrakis-chain");
|
||||
search_paths.push_back(std::string(home) + "/dragonx/src/dragonxd");
|
||||
search_paths.push_back(std::string(home) + "/bin/dragonxd");
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
// macOS app bundle
|
||||
search_paths.push_back("/Applications/DragonX.app/Contents/MacOS/hush-arrakis-chain");
|
||||
search_paths.push_back("/Applications/DragonX.app/Contents/MacOS/dragonxd");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -403,7 +393,7 @@ bool EmbeddedDaemon::startProcess(const std::string& binary_path, const std::vec
|
||||
|
||||
// Launch daemon with CREATE_NEW_CONSOLE (hidden via SW_HIDE).
|
||||
// The daemon binary must NOT be in the data directory (%APPDATA%\Hush\DRAGONX)
|
||||
// — it must be in <exe_dir>/hush3/ to avoid conflicts with lock files and data.
|
||||
// — it must be in <exe_dir>/dragonx/ to avoid conflicts with lock files and data.
|
||||
STARTUPINFOA si;
|
||||
PROCESS_INFORMATION pi;
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
@@ -564,7 +554,7 @@ void EmbeddedDaemon::stop(int wait_ms)
|
||||
};
|
||||
|
||||
if (tracked_alive) {
|
||||
// Our tracked process (hushd.exe launched directly) is still alive.
|
||||
// Our tracked process (dragonxd.exe launched directly) is still alive.
|
||||
// The RPC "stop" was already sent by the caller — wait for it to exit.
|
||||
DEBUG_LOGF("Waiting up to %d ms for tracked daemon process to exit...\n", wait_ms);
|
||||
if (!pollWait(process_handle_, wait_ms)) {
|
||||
@@ -577,33 +567,33 @@ void EmbeddedDaemon::stop(int wait_ms)
|
||||
process_handle_ = nullptr;
|
||||
} else {
|
||||
// Tracked handle is dead (batch file case: cmd.exe already exited).
|
||||
// The real hushd.exe may still be running as an orphan.
|
||||
// The real dragonxd.exe may still be running as an orphan.
|
||||
if (process_handle_ != nullptr) {
|
||||
CloseHandle(process_handle_);
|
||||
process_handle_ = nullptr;
|
||||
}
|
||||
|
||||
// Find the real hushd.exe process by name
|
||||
DWORD hushd_pid = findProcessByName("hushd.exe");
|
||||
if (hushd_pid != 0) {
|
||||
DEBUG_LOGF("Found orphaned hushd.exe (PID %lu) — waiting for RPC stop to take effect...\n", hushd_pid);
|
||||
HANDLE hProc = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, FALSE, hushd_pid);
|
||||
// Find the real dragonxd.exe process by name
|
||||
DWORD dragonxd_pid = findProcessByName("dragonxd.exe");
|
||||
if (dragonxd_pid != 0) {
|
||||
DEBUG_LOGF("Found orphaned dragonxd.exe (PID %lu) — waiting for RPC stop to take effect...\n", dragonxd_pid);
|
||||
HANDLE hProc = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, FALSE, dragonxd_pid);
|
||||
if (hProc) {
|
||||
// RPC stop was already sent — wait for graceful exit
|
||||
if (!pollWait(hProc, wait_ms)) {
|
||||
DEBUG_LOGF("Timeout — forcing hushd.exe (PID %lu) termination...\n", hushd_pid);
|
||||
DEBUG_LOGF("Timeout — forcing dragonxd.exe (PID %lu) termination...\n", dragonxd_pid);
|
||||
TerminateProcess(hProc, 1);
|
||||
WaitForSingleObject(hProc, 2000);
|
||||
}
|
||||
drainOutput();
|
||||
CloseHandle(hProc);
|
||||
DEBUG_LOGF("hushd.exe stopped\n");
|
||||
DEBUG_LOGF("dragonxd.exe stopped\n");
|
||||
} else {
|
||||
DEBUG_LOGF("Could not open hushd.exe process (PID %lu), error %lu\n",
|
||||
hushd_pid, GetLastError());
|
||||
DEBUG_LOGF("Could not open dragonxd.exe process (PID %lu), error %lu\n",
|
||||
dragonxd_pid, GetLastError());
|
||||
}
|
||||
} else {
|
||||
DEBUG_LOGF("No hushd.exe process found — daemon may have already exited\n");
|
||||
DEBUG_LOGF("No dragonxd.exe process found — daemon may have already exited\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -738,11 +728,11 @@ bool EmbeddedDaemon::startProcess(const std::string& binary_path, const std::vec
|
||||
close(pipefd[0]); // Close read end
|
||||
|
||||
// Put child in its own process group so we can kill the entire
|
||||
// group later (including hushd spawned by a wrapper script).
|
||||
// Without this, SIGTERM only kills the shell, leaving hushd orphaned.
|
||||
// group later (including dragonxd spawned by a wrapper script).
|
||||
// Without this, SIGTERM only kills the shell, leaving dragonxd orphaned.
|
||||
setpgid(0, 0);
|
||||
|
||||
// Change to the daemon binary's directory so hushd can find
|
||||
// Change to the daemon binary's directory so dragonxd can find
|
||||
// sapling params via its PWD search path (same as CreateProcessA
|
||||
// lpCurrentDirectory on Windows).
|
||||
{
|
||||
@@ -769,8 +759,7 @@ bool EmbeddedDaemon::startProcess(const std::string& binary_path, const std::vec
|
||||
bool is_script = false;
|
||||
if (binary_path.size() >= 3) {
|
||||
std::string ext = binary_path.substr(binary_path.size() - 3);
|
||||
if (ext == ".sh" || binary_path.find("hush-arrakis-chain") != std::string::npos ||
|
||||
binary_path.find("dragonxd") != std::string::npos) {
|
||||
if (ext == ".sh" || binary_path.find("dragonxd") != std::string::npos) {
|
||||
// Check if it's a script by looking at first bytes
|
||||
FILE* f = fopen(binary_path.c_str(), "r");
|
||||
if (f) {
|
||||
@@ -828,7 +817,7 @@ double EmbeddedDaemon::getMemoryUsageMB() const
|
||||
if (process_pid_ <= 0) return 0.0;
|
||||
|
||||
// The tracked PID is often a bash wrapper script; the real daemon
|
||||
// (hushd) is a child in the same process group. Sum VmRSS for every
|
||||
// (dragonxd) is a child in the same process group. Sum VmRSS for every
|
||||
// process whose PGID matches our tracked PID.
|
||||
double total_rss_mb = 0.0;
|
||||
|
||||
@@ -919,8 +908,8 @@ void EmbeddedDaemon::stop(int wait_ms)
|
||||
|
||||
// Send SIGTERM to the entire process group (negative PID).
|
||||
// This ensures that if dragonxd is a shell script wrapper,
|
||||
// both bash AND the actual hushd child receive the signal.
|
||||
// Without this, only bash is killed and hushd is orphaned.
|
||||
// both bash AND the actual dragonxd child receive the signal.
|
||||
// Without this, only bash is killed and dragonxd is orphaned.
|
||||
DEBUG_LOGF("Sending SIGTERM to process group -%d\n", process_pid_);
|
||||
kill(-process_pid_, SIGTERM);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user