Browse Source

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
0.8
gavinandresen 14 years ago
parent
commit
bdde31d787
  1. 23
      init.cpp
  2. 2
      irc.cpp
  3. 8
      main.cpp
  4. 10
      rpc.cpp
  5. 2
      serialize.h
  6. 8
      ui.cpp
  7. 11
      util.h

23
init.cpp

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

2
irc.cpp

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

8
main.cpp

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

10
rpc.cpp

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

2
serialize.h

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

8
ui.cpp

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

11
util.h

@ -417,6 +417,17 @@ inline int64 GetArg(const string& strArg, int64 nDefault)
return 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) inline string FormatVersion(int nVersion)
{ {
if (nVersion%100 == 0) if (nVersion%100 == 0)

Loading…
Cancel
Save