aboutsummaryrefslogtreecommitdiff
path: root/src/db.cpp
diff options
context:
space:
mode:
authorMike Hearn <hearn@google.com>2013-05-07 15:16:25 +0200
committerMike Hearn <hearn@google.com>2013-06-19 16:28:52 +0200
commit0e4b31755534fac4ea6c20a60f719e3694252220 (patch)
tree80f576f67c855485e5d82007b98a45536bbf2f9a /src/db.cpp
parent70e7fba06da36218688a4cae4a5d12332c714247 (diff)
Introduce a CChainParameters singleton class and regtest mode.
The new class is accessed via the Params() method and holds most things that vary between main, test and regtest networks. The regtest mode has two purposes, one is to run the bitcoind/bitcoinj comparison tool which compares two separate implementations of the Bitcoin protocol looking for divergence. The other is that when run, you get a local node which can mine a single block instantly, which is highly convenient for testing apps during development as there's no need to wait 10 minutes for a block on the testnet.
Diffstat (limited to 'src/db.cpp')
-rw-r--r--src/db.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/db.cpp b/src/db.cpp
index 1f53917602..93f3f5d8c4 100644
--- a/src/db.cpp
+++ b/src/db.cpp
@@ -3,6 +3,7 @@
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+#include "chainparams.h"
#include "db.h"
#include "util.h"
#include "hash.h"
@@ -488,8 +489,6 @@ void CDBEnv::Flush(bool fShutdown)
// CAddrDB
//
-unsigned char CAddrDB::pchMessageStart[4] = { 0x00, 0x00, 0x00, 0x00 };
-
CAddrDB::CAddrDB()
{
pathAddr = GetDataDir() / "peers.dat";
@@ -504,7 +503,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(CAddrDB::pchMessageStart);
+ ssPeers << FLATDATA(Params().MessageStart());
ssPeers << addr;
uint256 hash = Hash(ssPeers.begin(), ssPeers.end());
ssPeers << hash;
@@ -569,11 +568,11 @@ bool CAddrDB::Read(CAddrMan& addr)
unsigned char pchMsgTmp[4];
try {
- // de-serialize file header (CAddrDB::pchMessageStart magic number) and
+ // de-serialize file header (network specific magic number) and ..
ssPeers >> FLATDATA(pchMsgTmp);
- // verify the network matches ours
- if (memcmp(pchMsgTmp, CAddrDB::pchMessageStart, sizeof(pchMsgTmp)))
+ // ... verify the network matches ours
+ if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp)))
return error("CAddrman::Read() : invalid network magic number");
// de-serialize address data into one CAddrMan object