Skip to content

Commit 549e69a

Browse files
committed
Merge pull request #3449
8b9adca Allow `-noserver` with bitcoind (Wladimir J. van der Laan)
2 parents d696820 + 8b9adca commit 549e69a

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

src/bitcoind.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
* Use the buttons <code>Namespaces</code>, <code>Classes</code> or <code>Files</code> at the top of the page to start navigating the code.
3131
*/
3232

33+
static bool fDaemon;
34+
3335
void DetectShutdownThread(boost::thread_group* threadGroup)
3436
{
3537
bool fShutdown = ShutdownRequested();
@@ -108,6 +110,8 @@ bool AppInit(int argc, char* argv[])
108110
fDaemon = GetBoolArg("-daemon", false);
109111
if (fDaemon)
110112
{
113+
fprintf(stdout, "Bitcoin server starting\n");
114+
111115
// Daemonize
112116
pid_t pid = fork();
113117
if (pid < 0)
@@ -127,9 +131,10 @@ bool AppInit(int argc, char* argv[])
127131
fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
128132
}
129133
#endif
134+
SoftSetBoolArg("-server", true);
130135

131136
detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup));
132-
fRet = AppInit2(threadGroup, true);
137+
fRet = AppInit2(threadGroup);
133138
}
134139
catch (std::exception& e) {
135140
PrintExceptionContinue(&e, "AppInit()");

src/init.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,7 @@ std::string HelpMessage(HelpMessageMode hmm)
242242
strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n";
243243
strUsage += " -regtest " + _("Enter regression test mode, which uses a special chain in which blocks can be solved instantly.") + "\n";
244244
strUsage += " " + _("This is intended for regression testing tools and app development.") + "\n";
245-
if (hmm == HMM_BITCOIN_QT)
246-
{
247-
strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n";
248-
}
245+
strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n";
249246

250247
if (hmm == HMM_BITCOIND)
251248
{
@@ -356,7 +353,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
356353
/** Initialize bitcoin.
357354
* @pre Parameters should be parsed and config file should be read.
358355
*/
359-
bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
356+
bool AppInit2(boost::thread_group& threadGroup)
360357
{
361358
// ********************************************************* Step 1: setup
362359
#ifdef _MSC_VER
@@ -483,11 +480,7 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
483480
else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS)
484481
nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS;
485482

486-
if (fDaemon || fForceServer)
487-
fServer = true;
488-
else
489-
fServer = GetBoolArg("-server", false);
490-
483+
fServer = GetBoolArg("-server", false);
491484
fPrintToConsole = GetBoolArg("-printtoconsole", false);
492485
fLogTimestamps = GetBoolArg("-logtimestamps", true);
493486
#ifdef ENABLE_WALLET
@@ -569,9 +562,6 @@ bool AppInit2(boost::thread_group& threadGroup, bool fForceServer)
569562
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
570563
std::ostringstream strErrors;
571564

572-
if (fDaemon)
573-
fprintf(stdout, "Bitcoin server starting\n");
574-
575565
if (nScriptCheckThreads) {
576566
LogPrintf("Using %u threads for script verification\n", nScriptCheckThreads);
577567
for (int i=0; i<nScriptCheckThreads-1; i++)

src/init.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extern CWallet* pwalletMain;
2020
void StartShutdown();
2121
bool ShutdownRequested();
2222
void Shutdown();
23-
bool AppInit2(boost::thread_group& threadGroup, bool fForceServer);
23+
bool AppInit2(boost::thread_group& threadGroup);
2424

2525
/* The help message mode determines what help message to show */
2626
enum HelpMessageMode

src/qt/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int main(int argc, char *argv[])
289289
QObject::connect(pollShutdownTimer, SIGNAL(timeout()), guiref, SLOT(detectShutdown()));
290290
pollShutdownTimer->start(200);
291291

292-
if(AppInit2(threadGroup, false))
292+
if(AppInit2(threadGroup))
293293
{
294294
{
295295
// Put this in a block, so that the Model objects are cleaned up before

src/util.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
121121
extern bool fDebug;
122122
extern bool fPrintToConsole;
123123
extern bool fPrintToDebugLog;
124-
extern bool fDaemon;
125124
extern bool fServer;
126125
extern std::string strMiscWarning;
127126
extern bool fNoListen;

0 commit comments

Comments
 (0)