aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2011-06-26 19:23:24 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2011-06-26 19:23:24 +0200
commite8ef3da7133dd9fc411fa8b3cc8b8fc2f9c58a98 (patch)
treea6ff0ef6f8cdd85323acc1233a29891346b994fc /src/init.cpp
parentd99f5a470c8c4e80223f7a78679db58db78ee979 (diff)
update core to d0d80170a2ca73004e08fb85007fe055cbf4e411 (CWallet class)
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/init.cpp b/src/init.cpp
index cbd9fc0219..e4605a2b42 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -7,13 +7,15 @@
#include "net.h"
#include "init.h"
#include "strlcpy.h"
-#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
using namespace std;
using namespace boost;
+CWallet* pwalletMain;
+
//////////////////////////////////////////////////////////////////////////////
//
// Shutdown
@@ -46,6 +48,8 @@ void Shutdown(void* parg)
StopNode();
DBFlush(true);
boost::filesystem::remove(GetPidFile());
+ UnregisterWallet(pwalletMain);
+ delete pwalletMain;
CreateThread(ExitTimeout, NULL);
Sleep(50);
printf("Bitcoin exiting\n\n");
@@ -137,10 +141,19 @@ bool AppInit2(int argc, char* argv[])
if (mapArgs.count("-datadir"))
{
- filesystem::path pathDataDir = filesystem::system_complete(mapArgs["-datadir"]);
- strlcpy(pszSetDataDir, pathDataDir.string().c_str(), sizeof(pszSetDataDir));
+ if (filesystem::is_directory(filesystem::system_complete(mapArgs["-datadir"])))
+ {
+ filesystem::path pathDataDir = filesystem::system_complete(mapArgs["-datadir"]);
+ strlcpy(pszSetDataDir, pathDataDir.string().c_str(), sizeof(pszSetDataDir));
+ }
+ else
+ {
+ fprintf(stderr, "Error: Specified directory does not exist\n");
+ Shutdown(NULL);
+ }
}
+
ReadConfigFile(mapArgs, mapMultiArgs); // Must be done after processing datadir
if (mapArgs.count("-?") || mapArgs.count("--help"))
@@ -372,16 +385,19 @@ bool AppInit2(int argc, char* argv[])
printf("Loading wallet...\n");
nStart = GetTimeMillis();
bool fFirstRun;
- if (!LoadWallet(fFirstRun))
+ pwalletMain = new CWallet("wallet.dat");
+ if (!pwalletMain->LoadWallet(fFirstRun))
strErrors += _("Error loading wallet.dat \n");
printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart);
+ RegisterWallet(pwalletMain);
+
CBlockIndex *pindexRescan = pindexBest;
if (GetBoolArg("-rescan"))
pindexRescan = pindexGenesisBlock;
else
{
- CWalletDB walletdb;
+ CWalletDB walletdb("wallet.dat");
CBlockLocator locator;
if (walletdb.ReadBestBlock(locator))
pindexRescan = locator.GetBlockIndex();
@@ -390,7 +406,7 @@ bool AppInit2(int argc, char* argv[])
{
printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
nStart = GetTimeMillis();
- ScanForWalletTransactions(pindexRescan, true);
+ pwalletMain->ScanForWalletTransactions(pindexRescan, true);
printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
}
@@ -399,10 +415,11 @@ bool AppInit2(int argc, char* argv[])
//// debug print
printf("mapBlockIndex.size() = %d\n", mapBlockIndex.size());
printf("nBestHeight = %d\n", nBestHeight);
- printf("mapKeys.size() = %d\n", mapKeys.size());
+ printf("mapKeys.size() = %d\n", pwalletMain->mapKeys.size());
+ printf("setKeyPool.size() = %d\n", pwalletMain->setKeyPool.size());
printf("mapPubKeys.size() = %d\n", mapPubKeys.size());
- printf("mapWallet.size() = %d\n", mapWallet.size());
- printf("mapAddressBook.size() = %d\n", mapAddressBook.size());
+ printf("mapWallet.size() = %d\n", pwalletMain->mapWallet.size());
+ printf("mapAddressBook.size() = %d\n", pwalletMain->mapAddressBook.size());
if (!strErrors.empty())
{
@@ -411,7 +428,7 @@ bool AppInit2(int argc, char* argv[])
}
// Add wallet transactions that aren't already in a block to mapTransactions
- ReacceptWalletTransactions();
+ pwalletMain->ReacceptWalletTransactions();
//
// Parameters