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.
This commit is contained in:
11
src/db.cpp
11
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
|
||||
|
||||
Reference in New Issue
Block a user