All boolean options/flags now work the same way.

git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@194 1a98c847-1fd6-4fd8-948a-caf3550aa51b
This commit is contained in:
gavinandresen 2010-12-03 19:38:09 +00:00
parent bfd471f53e
commit bdde31d787
7 changed files with 33 additions and 31 deletions

View File

@ -206,14 +206,11 @@ bool AppInit2(int argc, char* argv[])
return false;
}
if (mapArgs.count("-debug"))
fDebug = true;
fDebug = GetBoolArg("-debug");
if (mapArgs.count("-printtodebugger"))
fPrintToDebugger = true;
fPrintToDebugger = GetBoolArg("-printtodebugger");
if (mapArgs.count("-testnet"))
fTestNet = true;
fTestNet = GetBoolArg("-testnet");
if (fCommandLine)
{
@ -232,7 +229,7 @@ bool AppInit2(int argc, char* argv[])
#endif
printf("Default data directory %s\n", GetDefaultDataDir().c_str());
if (mapArgs.count("-loadblockindextest"))
if (GetBoolArg("-loadblockindextest"))
{
CTxDB txdb("r");
txdb.LoadBlockIndex();
@ -348,7 +345,7 @@ bool AppInit2(int argc, char* argv[])
//
// Parameters
//
if (mapArgs.count("-printblockindex") || mapArgs.count("-printblocktree"))
if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree"))
{
PrintBlockTree();
return false;
@ -377,13 +374,7 @@ bool AppInit2(int argc, char* argv[])
return false;
}
if (mapArgs.count("-gen"))
{
if (mapArgs["-gen"].empty())
fGenerateBitcoins = true;
else
fGenerateBitcoins = (atoi(mapArgs["-gen"].c_str()) != 0);
}
fGenerateBitcoins = GetBoolArg("-gen");
if (mapArgs.count("-proxy"))
{
@ -434,7 +425,7 @@ bool AppInit2(int argc, char* argv[])
if (!CreateThread(StartNode, NULL))
wxMessageBox("Error: CreateThread(StartNode) failed", "Bitcoin");
if (mapArgs.count("-server") || fDaemon)
if (GetBoolArg("-server") || fDaemon)
CreateThread(ThreadRPCServer, NULL);
#if defined(__WXMSW__) && defined(GUI)

View File

@ -194,7 +194,7 @@ void ThreadIRCSeed2(void* parg)
{
if (mapArgs.count("-connect"))
return;
if (mapArgs.count("-noirc"))
if (GetBoolArg("-noirc"))
return;
printf("ThreadIRCSeed started\n");
int nErrorWait = 10;

View File

@ -1891,7 +1891,7 @@ string GetWarnings(string strFor)
int nPriority = 0;
string strStatusBar;
string strRPC;
if (mapArgs.count("-testsafemode"))
if (GetBoolArg("-testsafemode"))
strRPC = "test";
// Misc warnings like out of disk space and clock is wrong
@ -3123,7 +3123,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
dPriority += (double)nValueIn * nConf;
if (fDebug && mapArgs.count("-printpriority"))
if (fDebug && GetBoolArg("-printpriority"))
printf("priority nValueIn=%-12I64d nConf=%-5d dPriority=%-20.1f\n", nValueIn, nConf, dPriority);
}
@ -3135,7 +3135,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
else
mapPriority.insert(make_pair(-dPriority, &(*mi).second));
if (fDebug && mapArgs.count("-printpriority"))
if (fDebug && GetBoolArg("-printpriority"))
{
printf("priority %-20.1f %s\n%s", dPriority, tx.GetHash().ToString().substr(0,10).c_str(), tx.ToString().c_str());
if (porphan)
@ -3312,7 +3312,7 @@ void BitcoinMiner()
SetThreadPriority(THREAD_PRIORITY_LOWEST);
bool f4WaySSE2 = Detect128BitSSE2();
if (mapArgs.count("-4way"))
f4WaySSE2 = (mapArgs["-4way"] != "0");
f4WaySSE2 = GetBoolArg(mapArgs["-4way"]);
// Each thread has its own key and counter
CReserveKey reservekey;

10
rpc.cpp
View File

@ -1525,7 +1525,7 @@ void ThreadRPCServer2(void* parg)
return;
}
bool fUseSSL = (mapArgs.count("-rpcssl") > 0);
bool fUseSSL = GetBoolArg("-rpcssl");
asio::ip::address bindAddress = mapArgs.count("-rpcallowip") ? asio::ip::address_v4::any() : asio::ip::address_v4::loopback();
asio::io_service io_service;
@ -1552,7 +1552,7 @@ void ThreadRPCServer2(void* parg)
}
#else
if (fUseSSL)
throw runtime_error("-rpcssl=true, but bitcoin compiled without full openssl libraries.");
throw runtime_error("-rpcssl=1, but bitcoin compiled without full openssl libraries.");
#endif
loop
@ -1642,7 +1642,7 @@ void ThreadRPCServer2(void* parg)
// Observe safe mode
string strWarning = GetWarnings("rpc");
if (strWarning != "" && !mapArgs.count("-disablesafemode") && !setAllowInSafeMode.count(strMethod))
if (strWarning != "" && !GetBoolArg("-disablesafemode") && !setAllowInSafeMode.count(strMethod))
throw JSONRPCError(-2, string("Safe mode: ") + strWarning);
try
@ -1692,7 +1692,7 @@ Object CallRPC(const string& strMethod, const Array& params)
GetConfigFile().c_str()));
// Connect to localhost
bool fUseSSL = (mapArgs.count("-rpcssl") > 0);
bool fUseSSL = GetBoolArg("-rpcssl");
#ifdef USE_SSL
asio::io_service io_service;
ssl::context context(io_service, ssl::context::sslv23);
@ -1704,7 +1704,7 @@ Object CallRPC(const string& strMethod, const Array& params)
throw runtime_error("couldn't connect to server");
#else
if (fUseSSL)
throw runtime_error("-rpcssl=true, but bitcoin compiled without full openssl libraries.");
throw runtime_error("-rpcssl=1, but bitcoin compiled without full openssl libraries.");
ip::tcp::iostream stream(GetArg("-rpcconnect", "127.0.0.1"), GetArg("-rpcport", "8332"));
if (stream.fail())

View File

@ -25,7 +25,7 @@ class CDataStream;
class CAutoFile;
static const unsigned int MAX_SIZE = 0x02000000;
static const int VERSION = 31701;
static const int VERSION = 31702;
static const char* pszSubVer = "";

8
ui.cpp
View File

@ -391,7 +391,7 @@ void CMainFrame::OnIconize(wxIconizeEvent& event)
if (!event.Iconized())
fClosedToTray = false;
#if defined(__WXGTK__) || defined(__WXMAC_OSX__)
if (mapArgs.count("-minimizetotray")) {
if (GetBoolArg("-minimizetotray")) {
#endif
// The tray icon sometimes disappears on ubuntu karmic
// Hiding the taskbar button doesn't work cleanly on ubuntu lucid
@ -1633,7 +1633,7 @@ COptionsDialog::COptionsDialog(wxWindow* parent) : COptionsDialogBase(parent)
#endif
#if defined(__WXGTK__) || defined(__WXMAC_OSX__)
m_checkBoxStartOnSystemStartup->SetLabel(_("&Start Bitcoin on window system startup"));
if (!mapArgs.count("-minimizetotray"))
if (!GetBoolArg("-minimizetotray"))
{
// Minimize to tray is just too buggy on Linux
fMinimizeToTray = false;
@ -2741,10 +2741,10 @@ wxMenu* CMyTaskBarIcon::CreatePopupMenu()
void CreateMainWindow()
{
pframeMain = new CMainFrame(NULL);
if (mapArgs.count("-min"))
if (GetBoolArg("-min"))
pframeMain->Iconize(true);
#if defined(__WXGTK__) || defined(__WXMAC_OSX__)
if (!mapArgs.count("-minimizetotray"))
if (!GetBoolArg("-minimizetotray"))
fMinimizeToTray = false;
#endif
pframeMain->Show(true); // have to show first to get taskbar button to hide

11
util.h
View File

@ -417,6 +417,17 @@ inline int64 GetArg(const string& strArg, int64 nDefault)
return nDefault;
}
inline bool GetBoolArg(const string& strArg)
{
if (mapArgs.count(strArg))
{
if (mapArgs[strArg].empty())
return true;
return (atoi(mapArgs[strArg]) != 0);
}
return false;
}
inline string FormatVersion(int nVersion)
{
if (nVersion%100 == 0)