mirror of
https://github.com/jwinterm/myriadcoin.git
synced 2026-10-21 06:18:39 +02:00
Myriadcoin 0.11 port
This commit is contained in:
+45
-56
@@ -1,18 +1,19 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "clientversion.h"
|
||||
#include "rpcserver.h"
|
||||
#include "rpcclient.h"
|
||||
#include "init.h"
|
||||
#include "main.h"
|
||||
#include "noui.h"
|
||||
#include "ui_interface.h"
|
||||
#include "scheduler.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
/* Introduction text for doxygen: */
|
||||
|
||||
@@ -20,7 +21,7 @@
|
||||
*
|
||||
* \section intro_sec Introduction
|
||||
*
|
||||
* This is the developer documentation of the reference client for an experimental new digital currency called Bitcoin (http://www.bitcoin.org/),
|
||||
* This is the developer documentation of the reference client for an experimental new digital currency called Bitcoin (https://www.bitcoin.org/),
|
||||
* which enables instant payments to anyone, anywhere in the world. Bitcoin uses peer-to-peer technology to operate
|
||||
* with no central authority: managing transactions and issuing money are carried out collectively by the network.
|
||||
*
|
||||
@@ -32,7 +33,7 @@
|
||||
|
||||
static bool fDaemon;
|
||||
|
||||
void DetectShutdownThread(boost::thread_group* threadGroup)
|
||||
void WaitForShutdown(boost::thread_group* threadGroup)
|
||||
{
|
||||
bool fShutdown = ShutdownRequested();
|
||||
// Tell the main threads to shutdown.
|
||||
@@ -55,16 +56,39 @@ void DetectShutdownThread(boost::thread_group* threadGroup)
|
||||
bool AppInit(int argc, char* argv[])
|
||||
{
|
||||
boost::thread_group threadGroup;
|
||||
boost::thread* detectShutdownThread = NULL;
|
||||
CScheduler scheduler;
|
||||
|
||||
bool fRet = false;
|
||||
|
||||
//
|
||||
// Parameters
|
||||
//
|
||||
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
||||
ParseParameters(argc, argv);
|
||||
|
||||
// Process help and version before taking care about datadir
|
||||
if (mapArgs.count("-?") || mapArgs.count("-help") || mapArgs.count("-version"))
|
||||
{
|
||||
std::string strUsage = _("Myriadcoin Core Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n";
|
||||
|
||||
if (mapArgs.count("-version"))
|
||||
{
|
||||
strUsage += LicenseInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
strUsage += "\n" + _("Usage:") + "\n" +
|
||||
" myriadcoind [options] " + _("Start Myriadcoin Core Daemon") + "\n";
|
||||
|
||||
strUsage += "\n" + HelpMessage(HMM_BITCOIND);
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s", strUsage.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//
|
||||
// Parameters
|
||||
//
|
||||
// If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
|
||||
ParseParameters(argc, argv);
|
||||
if (!boost::filesystem::is_directory(GetDataDir(false)))
|
||||
{
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str());
|
||||
@@ -73,34 +97,16 @@ bool AppInit(int argc, char* argv[])
|
||||
try
|
||||
{
|
||||
ReadConfigFile(mapArgs, mapMultiArgs);
|
||||
} catch(std::exception &e) {
|
||||
} catch (const std::exception& e) {
|
||||
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (TestNet() calls are only valid after this clause)
|
||||
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
if (!SelectParamsFromCommandLine()) {
|
||||
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mapArgs.count("-?") || mapArgs.count("--help"))
|
||||
{
|
||||
// First part of help message is specific to bitcoind / RPC client
|
||||
std::string strUsage = _("Myriadcoin Core Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n\n" +
|
||||
_("Usage:") + "\n" +
|
||||
" myriadcoind [options] " + _("Start Myriadcoin Core Daemon") + "\n" +
|
||||
_("Usage (deprecated, use myriadcoin-cli):") + "\n" +
|
||||
" myriadcoind [options] <command> [params] " + _("Send command to Myriadcoin Core") + "\n" +
|
||||
" myriadcoind [options] help " + _("List commands") + "\n" +
|
||||
" myriadcoind [options] help <command> " + _("Get help for a command") + "\n";
|
||||
|
||||
strUsage += "\n" + HelpMessage(HMM_BITCOIND);
|
||||
strUsage += "\n" + HelpMessageCli(false);
|
||||
|
||||
fprintf(stdout, "%s", strUsage.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Command-line RPC
|
||||
bool fCommandLine = false;
|
||||
for (int i = 1; i < argc; i++)
|
||||
@@ -109,8 +115,8 @@ bool AppInit(int argc, char* argv[])
|
||||
|
||||
if (fCommandLine)
|
||||
{
|
||||
int ret = CommandLineRPC(argc, argv);
|
||||
exit(ret);
|
||||
fprintf(stderr, "Error: There is no RPC client functionality in myriadcoind anymore. Use the myriadcoin-cli utility instead.\n");
|
||||
exit(1);
|
||||
}
|
||||
#ifndef WIN32
|
||||
fDaemon = GetBoolArg("-daemon", false);
|
||||
@@ -127,7 +133,6 @@ bool AppInit(int argc, char* argv[])
|
||||
}
|
||||
if (pid > 0) // Parent process, pid is child process id
|
||||
{
|
||||
CreatePidFile(GetPidFile(), pid);
|
||||
return true;
|
||||
}
|
||||
// Child process falls through to rest of initialization
|
||||
@@ -139,10 +144,9 @@ bool AppInit(int argc, char* argv[])
|
||||
#endif
|
||||
SoftSetBoolArg("-server", true);
|
||||
|
||||
detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup));
|
||||
fRet = AppInit2(threadGroup);
|
||||
fRet = AppInit2(threadGroup, scheduler);
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
catch (const std::exception& e) {
|
||||
PrintExceptionContinue(&e, "AppInit()");
|
||||
} catch (...) {
|
||||
PrintExceptionContinue(NULL, "AppInit()");
|
||||
@@ -150,20 +154,12 @@ bool AppInit(int argc, char* argv[])
|
||||
|
||||
if (!fRet)
|
||||
{
|
||||
if (detectShutdownThread)
|
||||
detectShutdownThread->interrupt();
|
||||
|
||||
threadGroup.interrupt_all();
|
||||
// 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
|
||||
// thread-blocking-waiting-for-another-thread-during-startup case
|
||||
}
|
||||
|
||||
if (detectShutdownThread)
|
||||
{
|
||||
detectShutdownThread->join();
|
||||
delete detectShutdownThread;
|
||||
detectShutdownThread = NULL;
|
||||
} else {
|
||||
WaitForShutdown(&threadGroup);
|
||||
}
|
||||
Shutdown();
|
||||
|
||||
@@ -174,15 +170,8 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
SetupEnvironment();
|
||||
|
||||
bool fRet = false;
|
||||
|
||||
// Connect bitcoind signal handlers
|
||||
noui_connect();
|
||||
|
||||
fRet = AppInit(argc, argv);
|
||||
|
||||
if (fRet && fDaemon)
|
||||
return 0;
|
||||
|
||||
return (fRet ? 0 : 1);
|
||||
return (AppInit(argc, argv) ? 0 : 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user