aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/db.cpp11
-rw-r--r--src/db.h10
-rw-r--r--src/init.cpp1
-rw-r--r--src/wallet.h4
-rw-r--r--src/walletdb.h4
5 files changed, 22 insertions, 8 deletions
diff --git a/src/db.cpp b/src/db.cpp
index fd4c67d552..1f53917602 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -5,10 +5,12 @@
#include "db.h"
#include "util.h"
-#include "main.h"
+#include "hash.h"
+#include "addrman.h"
#include <boost/version.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
+#include <openssl/rand.h>
#ifndef WIN32
#include "sys/stat.h"
@@ -486,6 +488,7 @@ void CDBEnv::Flush(bool fShutdown)
// CAddrDB
//
+unsigned char CAddrDB::pchMessageStart[4] = { 0x00, 0x00, 0x00, 0x00 };
CAddrDB::CAddrDB()
{
@@ -501,7 +504,7 @@ bool CAddrDB::Write(const CAddrMan& addr)
// serialize addresses, checksum data up to that point, then append csum
CDataStream ssPeers(SER_DISK, CLIENT_VERSION);
- ssPeers << FLATDATA(pchMessageStart);
+ ssPeers << FLATDATA(CAddrDB::pchMessageStart);
ssPeers << addr;
uint256 hash = Hash(ssPeers.begin(), ssPeers.end());
ssPeers << hash;
@@ -566,11 +569,11 @@ bool CAddrDB::Read(CAddrMan& addr)
unsigned char pchMsgTmp[4];
try {
- // de-serialize file header (pchMessageStart magic number) and
+ // de-serialize file header (CAddrDB::pchMessageStart magic number) and
ssPeers >> FLATDATA(pchMsgTmp);
// verify the network matches ours
- if (memcmp(pchMsgTmp, pchMessageStart, sizeof(pchMsgTmp)))
+ if (memcmp(pchMsgTmp, CAddrDB::pchMessageStart, sizeof(pchMsgTmp)))
return error("CAddrman::Read() : invalid network magic number");
// de-serialize address data into one CAddrMan object
diff --git a/src/db.h b/src/db.h
index ea440c4960..92241f6cf2 100644
--- a/src/db.h
+++ b/src/db.h
@@ -5,22 +5,22 @@
#ifndef BITCOIN_DB_H
#define BITCOIN_DB_H
-#include "main.h"
+#include "sync.h"
+#include "serialize.h"
#include <map>
#include <string>
#include <vector>
+#include <boost/filesystem.hpp>
#include <db_cxx.h>
-class CAddress;
class CAddrMan;
class CBlockLocator;
class CDiskBlockIndex;
class CMasterKey;
class COutPoint;
class CWallet;
-class CWalletTx;
extern unsigned int nWalletDBUpdated;
@@ -318,10 +318,14 @@ class CAddrDB
{
private:
boost::filesystem::path pathAddr;
+ static unsigned char pchMessageStart[4];
+
public:
CAddrDB();
bool Write(const CAddrMan& addr);
bool Read(CAddrMan& addr);
+
+ static void SetMessageStart(unsigned char _pchMessageStart[]) { memcpy(CAddrDB::pchMessageStart, _pchMessageStart, sizeof(CAddrDB::pchMessageStart)); }
};
#endif // BITCOIN_DB_H
diff --git a/src/init.cpp b/src/init.cpp
index dcc43d8368..e4cb2f1d00 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -928,6 +928,7 @@ bool AppInit2(boost::thread_group& threadGroup)
nStart = GetTimeMillis();
{
+ CAddrDB::SetMessageStart(pchMessageStart);
CAddrDB adb;
if (!adb.Read(addrman))
printf("Invalid or missing peers.dat; recreating\n");
diff --git a/src/wallet.h b/src/wallet.h
index 7fcb8e13ce..22dce78e91 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -5,6 +5,8 @@
#ifndef BITCOIN_WALLET_H
#define BITCOIN_WALLET_H
+#include "walletdb.h"
+
#include <string>
#include <vector>
@@ -16,12 +18,12 @@
#include "script.h"
#include "ui_interface.h"
#include "util.h"
-#include "walletdb.h"
class CAccountingEntry;
class CWalletTx;
class CReserveKey;
class COutput;
+class CWalletDB;
/** (client) version numbers for particular wallet features */
enum WalletFeature
diff --git a/src/walletdb.h b/src/walletdb.h
index 8ae6c3ff49..9732eb29e4 100644
--- a/src/walletdb.h
+++ b/src/walletdb.h
@@ -11,6 +11,8 @@
class CKeyPool;
class CAccount;
class CAccountingEntry;
+class CWallet;
+class CWalletTx;
/** Error statuses for the wallet database */
enum DBErrors
@@ -160,4 +162,6 @@ public:
static bool Recover(CDBEnv& dbenv, std::string filename);
};
+bool BackupWallet(const CWallet& wallet, const std::string& strDest);
+
#endif // BITCOIN_WALLETDB_H