Browse Source

bitcoind changes to stop storing settings in wallet.dat.

pull/1/head
Gavin Andresen 11 years ago committed by Pieter Wuille
parent
commit
972060ce0e
  1. 12
      src/bitcoinrpc.cpp
  2. 47
      src/db.cpp
  3. 8
      src/db.h
  4. 9
      src/init.cpp
  5. 30
      src/main.cpp
  6. 20
      src/main.h
  7. 12
      src/net.cpp

12
src/bitcoinrpc.cpp

@ -301,7 +301,7 @@ Value getgenerate(const Array& params, bool fHelp) @@ -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) @@ -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) @@ -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));

47
src/db.cpp

@ -768,13 +768,6 @@ int CWalletDB::LoadWallet(CWallet* pwallet) @@ -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) @@ -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) @@ -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:

8
src/db.h

@ -473,18 +473,24 @@ public: @@ -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)
{

9
src/init.cpp

@ -473,8 +473,6 @@ bool AppInit2(int argc, char* argv[]) @@ -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[]) @@ -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;

30
src/main.cpp

@ -57,22 +57,12 @@ CScript COINBASE_FLAGS; @@ -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) @@ -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) @@ -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);

20
src/main.h

@ -77,13 +77,7 @@ extern CCriticalSection cs_setpwalletRegistered; @@ -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); @@ -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
{

12
src/net.cpp

@ -43,6 +43,7 @@ bool OpenNetworkConnection(const CAddress& addrConnect); @@ -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) @@ -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) @@ -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) @@ -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()

Loading…
Cancel
Save