aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2012-02-16 15:00:16 -0500
committerPieter Wuille <pieter.wuille@gmail.com>2012-02-26 23:21:33 +0100
commit972060ce0e9746c979ce0ddeeb997121414c1d58 (patch)
tree9c676a8281e62513e9ee4b5f68e01a197dc6edf2
parent4a10d4c6dcd04eb2496257754782150793ce53b1 (diff)
bitcoind changes to stop storing settings in wallet.dat.
-rw-r--r--src/bitcoinrpc.cpp12
-rw-r--r--src/db.cpp47
-rw-r--r--src/db.h8
-rw-r--r--src/init.cpp9
-rw-r--r--src/main.cpp30
-rw-r--r--src/main.h20
-rw-r--r--src/net.cpp12
7 files changed, 34 insertions, 104 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index c677b174ca..68cc17b518 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -301,7 +301,7 @@ Value getgenerate(const Array& params, bool fHelp)
"getgenerate\n"
"Returns true or false.");
- return (bool)fGenerateBitcoins;
+ return GetBoolArg("-gen");
}
@@ -320,13 +320,11 @@ Value setgenerate(const Array& params, bool fHelp)
if (params.size() > 1)
{
int nGenProcLimit = params[1].get_int();
- fLimitProcessors = (nGenProcLimit != -1);
- WriteSetting("fLimitProcessors", fLimitProcessors);
- if (nGenProcLimit != -1)
- WriteSetting("nLimitProcessors", nLimitProcessors = nGenProcLimit);
+ mapArgs["-genproclimit"] = itostr(nGenProcLimit);
if (nGenProcLimit == 0)
fGenerate = false;
}
+ mapArgs["-gen"] = (fGenerate ? "1" : "0");
GenerateBitcoins(fGenerate, pwalletMain);
return Value::null;
@@ -385,8 +383,8 @@ Value getmininginfo(const Array& params, bool fHelp)
obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
obj.push_back(Pair("errors", GetWarnings("statusbar")));
- obj.push_back(Pair("generate", (bool)fGenerateBitcoins));
- obj.push_back(Pair("genproclimit", (int)(fLimitProcessors ? nLimitProcessors : -1)));
+ obj.push_back(Pair("generate", GetBoolArg("-gen")));
+ obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1)));
obj.push_back(Pair("hashespersec", gethashespersec(params, false)));
obj.push_back(Pair("pooledtx", (uint64_t)nPooledTx));
obj.push_back(Pair("testnet", fTestNet));
diff --git a/src/db.cpp b/src/db.cpp
index 4d4a3c4696..b77a038b41 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -768,13 +768,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
vector<uint256> vWalletUpgrade;
bool fIsEncrypted = false;
- // Modify defaults
-#ifndef WIN32
- // Tray icon sometimes disappears on 9.10 karmic koala 64-bit, leaving no way to access the program
- fMinimizeToTray = false;
- fMinimizeOnClose = false;
-#endif
-
//// todo: shouldn't we catch exceptions and try to recover and continue?
CRITICAL_BLOCK(pwallet->cs_wallet)
{
@@ -916,38 +909,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
if (nFileVersion == 10300)
nFileVersion = 300;
}
- else if (strType == "setting")
- {
- string strKey;
- ssKey >> strKey;
-
- // Options
-#ifndef QT_GUI
- if (strKey == "fGenerateBitcoins") ssValue >> fGenerateBitcoins;
-#endif
- if (strKey == "nTransactionFee") ssValue >> nTransactionFee;
- if (strKey == "fLimitProcessors") ssValue >> fLimitProcessors;
- if (strKey == "nLimitProcessors") ssValue >> nLimitProcessors;
- if (strKey == "fMinimizeToTray") ssValue >> fMinimizeToTray;
- if (strKey == "fMinimizeOnClose") ssValue >> fMinimizeOnClose;
- if (strKey == "fUseProxy") ssValue >> fUseProxy;
- if (strKey == "addrProxy")
- {
- CAddress addr;
- CDataStream ssValue2 = ssValue;
- // 0.6.0rc1 saved this as a CService, which causes failure when parsing as a CAddress
- try
- {
- ssValue >> addr;
- addrProxy = addr;
- }
- catch (std::ios_base::failure &e)
- {
- ssValue2 >> addrProxy;
- }
- }
- if (fHaveUPnP && strKey == "fUseUPnP") ssValue >> fUseUPnP;
- }
else if (strType == "minversion")
{
int nMinVersion = 0;
@@ -973,14 +934,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet)
WriteTx(hash, pwallet->mapWallet[hash]);
printf("nFileVersion = %d\n", nFileVersion);
- printf("fGenerateBitcoins = %d\n", fGenerateBitcoins);
- printf("nTransactionFee = %"PRI64d"\n", nTransactionFee);
- printf("fMinimizeToTray = %d\n", fMinimizeToTray);
- printf("fMinimizeOnClose = %d\n", fMinimizeOnClose);
- printf("fUseProxy = %d\n", fUseProxy);
- printf("addrProxy = %s\n", addrProxy.ToString().c_str());
- if (fHaveUPnP)
- printf("fUseUPnP = %d\n", fUseUPnP);
// Rewrite encrypted wallets of versions 0.4.0 and 0.5.0rc:
diff --git a/src/db.h b/src/db.h
index 2611faa461..74cb5d8d5f 100644
--- a/src/db.h
+++ b/src/db.h
@@ -473,18 +473,24 @@ public:
return Erase(std::make_pair(std::string("pool"), nPool));
}
+ // Settings are no longer stored in wallet.dat; these are
+ // used only for backwards compatibility:
template<typename T>
bool ReadSetting(const std::string& strKey, T& value)
{
return Read(std::make_pair(std::string("setting"), strKey), value);
}
-
template<typename T>
bool WriteSetting(const std::string& strKey, const T& value)
{
nWalletDBUpdated++;
return Write(std::make_pair(std::string("setting"), strKey), value);
}
+ bool EraseSetting(const std::string& strKey)
+ {
+ nWalletDBUpdated++;
+ return Erase(std::make_pair(std::string("setting"), strKey));
+ }
bool WriteMinVersion(int nVersion)
{
diff --git a/src/init.cpp b/src/init.cpp
index 3a8fcdf524..b701e90e91 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -473,8 +473,6 @@ bool AppInit2(int argc, char* argv[])
return false;
}
- fGenerateBitcoins = GetBoolArg("-gen");
-
if (mapArgs.count("-proxy"))
{
fUseProxy = true;
@@ -520,13 +518,6 @@ bool AppInit2(int argc, char* argv[])
COINBASE_FLAGS << std::vector<unsigned char>(pszP2SH, pszP2SH+strlen(pszP2SH));
}
- // Command-line args override in-wallet settings:
-#if USE_UPNP
- fUseUPnP = GetBoolArg("-upnp", true);
-#else
- fUseUPnP = GetBoolArg("-upnp", false);
-#endif
-
if (!fNoListen)
{
std::string strError;
diff --git a/src/main.cpp b/src/main.cpp
index a9311e2ceb..a7bb71f011 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -57,22 +57,12 @@ CScript COINBASE_FLAGS;
const string strMessageMagic = "Bitcoin Signed Message:\n";
-
double dHashesPerSec;
int64 nHPSTimerStart;
// Settings
-int fGenerateBitcoins = false;
int64 nTransactionFee = 0;
-int fLimitProcessors = false;
-int nLimitProcessors = 1;
-int fMinimizeToTray = true;
-int fMinimizeOnClose = true;
-#if USE_UPNP
-int fUseUPnP = true;
-#else
-int fUseUPnP = false;
-#endif
+
//////////////////////////////////////////////////////////////////////////////
@@ -3289,6 +3279,10 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
void static ThreadBitcoinMiner(void* parg);
+static bool fGenerateBitcoins = false;
+static bool fLimitProcessors = false;
+static int nLimitProcessors = -1;
+
void static BitcoinMiner(CWallet *pwallet)
{
printf("BitcoinMiner started\n");
@@ -3464,13 +3458,13 @@ void static ThreadBitcoinMiner(void* parg)
void GenerateBitcoins(bool fGenerate, CWallet* pwallet)
{
- if (fGenerateBitcoins != fGenerate)
- {
- fGenerateBitcoins = fGenerate;
- WriteSetting("fGenerateBitcoins", fGenerateBitcoins);
- MainFrameRepaint();
- }
- if (fGenerateBitcoins)
+ fGenerateBitcoins = fGenerate;
+ nLimitProcessors = GetArg("-genproclimit", -1);
+ if (nLimitProcessors == 0)
+ fGenerateBitcoins = false;
+ fLimitProcessors = (nLimitProcessors != -1);
+
+ if (fGenerate)
{
int nProcessors = boost::thread::hardware_concurrency();
printf("%d processors\n", nProcessors);
diff --git a/src/main.h b/src/main.h
index d9f976c217..ac6d624e40 100644
--- a/src/main.h
+++ b/src/main.h
@@ -77,13 +77,7 @@ extern CCriticalSection cs_setpwalletRegistered;
extern std::set<CWallet*> setpwalletRegistered;
// Settings
-extern int fGenerateBitcoins;
extern int64 nTransactionFee;
-extern int fLimitProcessors;
-extern int nLimitProcessors;
-extern int fMinimizeToTray;
-extern int fMinimizeOnClose;
-extern int fUseUPnP;
@@ -127,20 +121,6 @@ std::string GetWarnings(std::string strFor);
bool GetWalletFile(CWallet* pwallet, std::string &strWalletFileOut);
-template<typename T>
-bool WriteSetting(const std::string& strKey, const T& value)
-{
- bool fOk = false;
- BOOST_FOREACH(CWallet* pwallet, setpwalletRegistered)
- {
- std::string strWalletFile;
- if (!GetWalletFile(pwallet, strWalletFile))
- continue;
- fOk |= CWalletDB(strWalletFile).WriteSetting(strKey, value);
- }
- return fOk;
-}
-
class CDiskTxPos
{
diff --git a/src/net.cpp b/src/net.cpp
index 546bc6adc8..5d45e10d05 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -43,6 +43,7 @@ bool OpenNetworkConnection(const CAddress& addrConnect);
//
bool fClient = false;
bool fAllowDNS = false;
+static bool fUseUPnP = false;
uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK);
CAddress addrLocalHost(CService("0.0.0.0", 0), nLocalServices);
static CNode* pnodeLocalHost = NULL;
@@ -1102,7 +1103,6 @@ void MapPort(bool fMapPort)
if (fUseUPnP != fMapPort)
{
fUseUPnP = fMapPort;
- WriteSetting("fUseUPnP", fUseUPnP);
}
if (fUseUPnP && vnThreadsRunning[THREAD_UPNP] < 1)
{
@@ -1711,6 +1711,14 @@ bool BindListenPort(string& strError)
void StartNode(void* parg)
{
+#ifdef USE_UPNP
+#if USE_UPNP
+ fUseUPnP = GetBoolArg("-upnp", true);
+#else
+ fUseUPnP = GetBoolArg("-upnp", false);
+#endif
+#endif
+
if (pnodeLocalHost == NULL)
pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices));
@@ -1812,7 +1820,7 @@ void StartNode(void* parg)
printf("Error: CreateThread(ThreadMessageHandler) failed\n");
// Generate coins in the background
- GenerateBitcoins(fGenerateBitcoins, pwalletMain);
+ GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain);
}
bool StopNode()