Browse Source

Globals: Remove a bunch of Params() calls from main.cpp:

1) Chainparams: Explicit CChainParams arg for main:

-AcceptBlock
-AcceptBlockHeader
-ActivateBestChain
-ConnectTip
-InitBlockIndex
-LoadExternalBlockFile
-VerifyDB parametric constructor

2) Also pickup more Params()\. in main.cpp

3) Pass nPruneAfterHeight explicitly to new FindFilesToPrune() in main.cpp
0.13
Jorge Timón 9 years ago
parent
commit
2e29e7e247
  1. 15
      src/init.cpp
  2. 56
      src/main.cpp
  3. 13
      src/main.h
  4. 6
      src/rpcblockchain.cpp
  5. 3
      src/test/test_bitcoin.cpp

15
src/init.cpp

@ -588,6 +588,7 @@ void CleanupBlockRevFiles()
void ThreadImport(std::vector<boost::filesystem::path> vImportFiles) void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
{ {
const CChainParams& chainparams = Params();
RenameThread("bitcoin-loadblk"); RenameThread("bitcoin-loadblk");
// -reindex // -reindex
if (fReindex) { if (fReindex) {
@ -601,14 +602,14 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
if (!file) if (!file)
break; // This error is logged in OpenBlockFile break; // This error is logged in OpenBlockFile
LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile); LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
LoadExternalBlockFile(file, &pos); LoadExternalBlockFile(chainparams, file, &pos);
nFile++; nFile++;
} }
pblocktree->WriteReindexing(false); pblocktree->WriteReindexing(false);
fReindex = false; fReindex = false;
LogPrintf("Reindexing finished\n"); LogPrintf("Reindexing finished\n");
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked): // To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
InitBlockIndex(); InitBlockIndex(chainparams);
} }
// hardcoded $DATADIR/bootstrap.dat // hardcoded $DATADIR/bootstrap.dat
@ -619,7 +620,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
CImportingNow imp; CImportingNow imp;
boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
LogPrintf("Importing bootstrap.dat...\n"); LogPrintf("Importing bootstrap.dat...\n");
LoadExternalBlockFile(file); LoadExternalBlockFile(chainparams, file);
RenameOver(pathBootstrap, pathBootstrapOld); RenameOver(pathBootstrap, pathBootstrapOld);
} else { } else {
LogPrintf("Warning: Could not open bootstrap file %s\n", pathBootstrap.string()); LogPrintf("Warning: Could not open bootstrap file %s\n", pathBootstrap.string());
@ -632,7 +633,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
if (file) { if (file) {
CImportingNow imp; CImportingNow imp;
LogPrintf("Importing blocks file %s...\n", path.string()); LogPrintf("Importing blocks file %s...\n", path.string());
LoadExternalBlockFile(file); LoadExternalBlockFile(chainparams, file);
} else { } else {
LogPrintf("Warning: Could not open blocks file %s\n", path.string()); LogPrintf("Warning: Could not open blocks file %s\n", path.string());
} }
@ -1297,7 +1298,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?")); return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
// Initialize the block index (no-op if non-empty database was already loaded) // Initialize the block index (no-op if non-empty database was already loaded)
if (!InitBlockIndex()) { if (!InitBlockIndex(chainparams)) {
strLoadError = _("Error initializing block database"); strLoadError = _("Error initializing block database");
break; break;
} }
@ -1332,7 +1333,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
} }
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", DEFAULT_CHECKLEVEL), if (!CVerifyDB().VerifyDB(chainparams, pcoinsdbview, GetArg("-checklevel", DEFAULT_CHECKLEVEL),
GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) { GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
strLoadError = _("Corrupted block database detected"); strLoadError = _("Corrupted block database detected");
break; break;
@ -1556,7 +1557,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
uiInterface.InitMessage(_("Activating best chain...")); uiInterface.InitMessage(_("Activating best chain..."));
// scan for better chains in the block chain database, that are not yet connected in the active best chain // scan for better chains in the block chain database, that are not yet connected in the active best chain
CValidationState state; CValidationState state;
if (!ActivateBestChain(state)) if (!ActivateBestChain(state, chainparams))
strErrors << "Failed to connect best block"; strErrors << "Failed to connect best block";
std::vector<boost::filesystem::path> vImportFiles; std::vector<boost::filesystem::path> vImportFiles;

56
src/main.cpp

@ -1939,6 +1939,7 @@ enum FlushStateMode {
* or always and in all cases if we're in prune mode and are deleting files. * or always and in all cases if we're in prune mode and are deleting files.
*/ */
bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) { bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
const CChainParams& chainparams = Params();
LOCK2(cs_main, cs_LastBlockFile); LOCK2(cs_main, cs_LastBlockFile);
static int64_t nLastWrite = 0; static int64_t nLastWrite = 0;
static int64_t nLastFlush = 0; static int64_t nLastFlush = 0;
@ -1947,7 +1948,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
bool fFlushForPrune = false; bool fFlushForPrune = false;
try { try {
if (fPruneMode && fCheckForPruning && !fReindex) { if (fPruneMode && fCheckForPruning && !fReindex) {
FindFilesToPrune(setFilesToPrune); FindFilesToPrune(setFilesToPrune, chainparams.PruneAfterHeight());
fCheckForPruning = false; fCheckForPruning = false;
if (!setFilesToPrune.empty()) { if (!setFilesToPrune.empty()) {
fFlushForPrune = true; fFlushForPrune = true;
@ -2147,8 +2148,8 @@ static int64_t nTimePostConnect = 0;
* Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock * Connect a new block to chainActive. pblock is either NULL or a pointer to a CBlock
* corresponding to pindexNew, to bypass loading it again from disk. * corresponding to pindexNew, to bypass loading it again from disk.
*/ */
bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, const CBlock *pblock) { bool static ConnectTip(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexNew, const CBlock* pblock)
const CChainParams& chainparams = Params(); {
assert(pindexNew->pprev == chainActive.Tip()); assert(pindexNew->pprev == chainActive.Tip());
mempool.check(pcoinsTip); mempool.check(pcoinsTip);
// Read block from disk. // Read block from disk.
@ -2280,8 +2281,8 @@ static void PruneBlockIndexCandidates() {
* Try to make some progress towards making pindexMostWork the active block. * Try to make some progress towards making pindexMostWork the active block.
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork. * pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
*/ */
static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, const CBlock *pblock) { static bool ActivateBestChainStep(CValidationState& state, const CChainParams& chainparams, CBlockIndex* pindexMostWork, const CBlock* pblock)
const CChainParams& chainparams = Params(); {
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
bool fInvalidFound = false; bool fInvalidFound = false;
const CBlockIndex *pindexOldTip = chainActive.Tip(); const CBlockIndex *pindexOldTip = chainActive.Tip();
@ -2314,7 +2315,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
// Connect new blocks. // Connect new blocks.
BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) { BOOST_REVERSE_FOREACH(CBlockIndex *pindexConnect, vpindexToConnect) {
if (!ConnectTip(state, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL)) { if (!ConnectTip(state, chainparams, pindexConnect, pindexConnect == pindexMostWork ? pblock : NULL)) {
if (state.IsInvalid()) { if (state.IsInvalid()) {
// The block violates a consensus rule. // The block violates a consensus rule.
if (!state.CorruptionPossible()) if (!state.CorruptionPossible())
@ -2355,10 +2356,10 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
* or an activated best chain. pblock is either NULL or a pointer to a block * or an activated best chain. pblock is either NULL or a pointer to a block
* that is already loaded (to avoid loading it again from disk). * that is already loaded (to avoid loading it again from disk).
*/ */
bool ActivateBestChain(CValidationState &state, const CBlock *pblock) { bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, const CBlock* pblock)
{
CBlockIndex *pindexNewTip = NULL; CBlockIndex *pindexNewTip = NULL;
CBlockIndex *pindexMostWork = NULL; CBlockIndex *pindexMostWork = NULL;
const CChainParams& chainparams = Params();
do { do {
boost::this_thread::interruption_point(); boost::this_thread::interruption_point();
@ -2371,7 +2372,7 @@ bool ActivateBestChain(CValidationState &state, const CBlock *pblock) {
if (pindexMostWork == NULL || pindexMostWork == chainActive.Tip()) if (pindexMostWork == NULL || pindexMostWork == chainActive.Tip())
return true; return true;
if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) if (!ActivateBestChainStep(state, chainparams, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL))
return false; return false;
pindexNewTip = chainActive.Tip(); pindexNewTip = chainActive.Tip();
@ -2850,9 +2851,9 @@ static bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state
return true; return true;
} }
bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex** ppindex, bool fRequested, CDiskBlockPos* dbp) /** Store block on disk. If dbp is non-NULL, the file is known to already reside on disk */
static bool AcceptBlock(const CBlock& block, CValidationState& state, const CChainParams& chainparams, CBlockIndex** ppindex, bool fRequested, CDiskBlockPos* dbp)
{ {
const CChainParams& chainparams = Params();
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
CBlockIndex *&pindex = *ppindex; CBlockIndex *&pindex = *ppindex;
@ -2942,7 +2943,7 @@ bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, c
// Store to disk // Store to disk
CBlockIndex *pindex = NULL; CBlockIndex *pindex = NULL;
bool ret = AcceptBlock(*pblock, state, &pindex, fRequested, dbp); bool ret = AcceptBlock(*pblock, state, chainparams, &pindex, fRequested, dbp);
if (pindex && pfrom) { if (pindex && pfrom) {
mapBlockSource[pindex->GetBlockHash()] = pfrom->GetId(); mapBlockSource[pindex->GetBlockHash()] = pfrom->GetId();
} }
@ -2951,7 +2952,7 @@ bool ProcessNewBlock(CValidationState& state, const CChainParams& chainparams, c
return error("%s: AcceptBlock FAILED", __func__); return error("%s: AcceptBlock FAILED", __func__);
} }
if (!ActivateBestChain(state, pblock)) if (!ActivateBestChain(state, chainparams, pblock))
return error("%s: ActivateBestChain failed", __func__); return error("%s: ActivateBestChain failed", __func__);
return true; return true;
@ -3041,13 +3042,13 @@ void UnlinkPrunedFiles(std::set<int>& setFilesToPrune)
} }
/* Calculate the block/rev files that should be deleted to remain under target*/ /* Calculate the block/rev files that should be deleted to remain under target*/
void FindFilesToPrune(std::set<int>& setFilesToPrune) void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight)
{ {
LOCK2(cs_main, cs_LastBlockFile); LOCK2(cs_main, cs_LastBlockFile);
if (chainActive.Tip() == NULL || nPruneTarget == 0) { if (chainActive.Tip() == NULL || nPruneTarget == 0) {
return; return;
} }
if (chainActive.Tip()->nHeight <= Params().PruneAfterHeight()) { if (chainActive.Tip()->nHeight <= nPruneAfterHeight) {
return; return;
} }
@ -3275,9 +3276,8 @@ CVerifyDB::~CVerifyDB()
uiInterface.ShowProgress("", 100); uiInterface.ShowProgress("", 100);
} }
bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth) bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, int nCheckLevel, int nCheckDepth)
{ {
const CChainParams& chainparams = Params();
LOCK(cs_main); LOCK(cs_main);
if (chainActive.Tip() == NULL || chainActive.Tip()->pprev == NULL) if (chainActive.Tip() == NULL || chainActive.Tip()->pprev == NULL)
return true; return true;
@ -3393,9 +3393,8 @@ bool LoadBlockIndex()
return true; return true;
} }
bool InitBlockIndex(const CChainParams& chainparams)
bool InitBlockIndex() { {
const CChainParams& chainparams = Params();
LOCK(cs_main); LOCK(cs_main);
// Initialize global variables that cannot be constructed at startup. // Initialize global variables that cannot be constructed at startup.
@ -3413,7 +3412,7 @@ bool InitBlockIndex() {
// Only add the genesis block if not reindexing (in which case we reuse the one already on disk) // Only add the genesis block if not reindexing (in which case we reuse the one already on disk)
if (!fReindex) { if (!fReindex) {
try { try {
CBlock &block = const_cast<CBlock&>(Params().GenesisBlock()); CBlock &block = const_cast<CBlock&>(chainparams.GenesisBlock());
// Start new block file // Start new block file
unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION); unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION);
CDiskBlockPos blockPos; CDiskBlockPos blockPos;
@ -3425,7 +3424,7 @@ bool InitBlockIndex() {
CBlockIndex *pindex = AddToBlockIndex(block); CBlockIndex *pindex = AddToBlockIndex(block);
if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) if (!ReceivedBlockTransactions(block, state, pindex, blockPos))
return error("LoadBlockIndex(): genesis block not accepted"); return error("LoadBlockIndex(): genesis block not accepted");
if (!ActivateBestChain(state, &block)) if (!ActivateBestChain(state, chainparams, &block))
return error("LoadBlockIndex(): genesis block cannot be activated"); return error("LoadBlockIndex(): genesis block cannot be activated");
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data // Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS); return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
@ -3437,11 +3436,8 @@ bool InitBlockIndex() {
return true; return true;
} }
bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskBlockPos *dbp)
bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
{ {
const CChainParams& chainparams = Params();
// Map of disk positions for blocks with unknown parent (only used for reindex) // Map of disk positions for blocks with unknown parent (only used for reindex)
static std::multimap<uint256, CDiskBlockPos> mapBlocksUnknownParent; static std::multimap<uint256, CDiskBlockPos> mapBlocksUnknownParent;
int64_t nStart = GetTimeMillis(); int64_t nStart = GetTimeMillis();
@ -3461,10 +3457,10 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
try { try {
// locate a header // locate a header
unsigned char buf[MESSAGE_START_SIZE]; unsigned char buf[MESSAGE_START_SIZE];
blkdat.FindByte(Params().MessageStart()[0]); blkdat.FindByte(chainparams.MessageStart()[0]);
nRewind = blkdat.GetPos()+1; nRewind = blkdat.GetPos()+1;
blkdat >> FLATDATA(buf); blkdat >> FLATDATA(buf);
if (memcmp(buf, Params().MessageStart(), MESSAGE_START_SIZE)) if (memcmp(buf, chainparams.MessageStart(), MESSAGE_START_SIZE))
continue; continue;
// read size // read size
blkdat >> nSize; blkdat >> nSize;
@ -3858,7 +3854,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
// best equivalent proof of work) than the best header chain we know about. // best equivalent proof of work) than the best header chain we know about.
send = mi->second->IsValid(BLOCK_VALID_SCRIPTS) && (pindexBestHeader != NULL) && send = mi->second->IsValid(BLOCK_VALID_SCRIPTS) && (pindexBestHeader != NULL) &&
(pindexBestHeader->GetBlockTime() - mi->second->GetBlockTime() < nOneMonth) && (pindexBestHeader->GetBlockTime() - mi->second->GetBlockTime() < nOneMonth) &&
(GetBlockProofEquivalentTime(*pindexBestHeader, *mi->second, *pindexBestHeader, Params().GetConsensus()) < nOneMonth); (GetBlockProofEquivalentTime(*pindexBestHeader, *mi->second, *pindexBestHeader, consensusParams) < nOneMonth);
if (!send) { if (!send) {
LogPrintf("%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom->GetId()); LogPrintf("%s: ignoring request from peer=%i for old block that isn't in the main chain\n", __func__, pfrom->GetId());
} }
@ -4701,7 +4697,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
uint256 alertHash = alert.GetHash(); uint256 alertHash = alert.GetHash();
if (pfrom->setKnown.count(alertHash) == 0) if (pfrom->setKnown.count(alertHash) == 0)
{ {
if (alert.ProcessAlert(Params().AlertKey())) if (alert.ProcessAlert(chainparams.AlertKey()))
{ {
// Relay // Relay
pfrom->setKnown.insert(alertHash); pfrom->setKnown.insert(alertHash);

13
src/main.h

@ -172,9 +172,9 @@ FILE* OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly = false);
/** Translation to a filesystem path */ /** Translation to a filesystem path */
boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix); boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix);
/** Import blocks from an external file */ /** Import blocks from an external file */
bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp = NULL); bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskBlockPos *dbp = NULL);
/** Initialize a new block tree database + block data on disk */ /** Initialize a new block tree database + block data on disk */
bool InitBlockIndex(); bool InitBlockIndex(const CChainParams& chainparams);
/** Load the block tree and coins database from disk */ /** Load the block tree and coins database from disk */
bool LoadBlockIndex(); bool LoadBlockIndex();
/** Unload database information */ /** Unload database information */
@ -199,7 +199,7 @@ std::string GetWarnings(const std::string& strFor);
/** Retrieve a transaction (from memory pool, or from disk, if possible) */ /** Retrieve a transaction (from memory pool, or from disk, if possible) */
bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Params& params, uint256 &hashBlock, bool fAllowSlow = false); bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Params& params, uint256 &hashBlock, bool fAllowSlow = false);
/** Find the best known block, and make it the tip of the block chain */ /** Find the best known block, and make it the tip of the block chain */
bool ActivateBestChain(CValidationState &state, const CBlock *pblock = NULL); bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, const CBlock* pblock = NULL);
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
/** /**
@ -217,7 +217,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
* *
* @param[out] setFilesToPrune The set of file indices that can be unlinked will be returned * @param[out] setFilesToPrune The set of file indices that can be unlinked will be returned
*/ */
void FindFilesToPrune(std::set<int>& setFilesToPrune); void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight);
/** /**
* Actually unlink the specified files * Actually unlink the specified files
@ -383,9 +383,6 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
/** Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held) */ /** Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held) */
bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true); bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
/** Store block on disk. If dbp is non-NULL, the file is known to already reside on disk */
bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex **pindex, bool fRequested, CDiskBlockPos* dbp);
class CBlockFileInfo class CBlockFileInfo
{ {
@ -446,7 +443,7 @@ class CVerifyDB {
public: public:
CVerifyDB(); CVerifyDB();
~CVerifyDB(); ~CVerifyDB();
bool VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth); bool VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, int nCheckLevel, int nCheckDepth);
}; };
/** Find the last common block between the parameter chain and a locator. */ /** Find the last common block between the parameter chain and a locator. */

6
src/rpcblockchain.cpp

@ -562,7 +562,7 @@ UniValue verifychain(const UniValue& params, bool fHelp)
if (params.size() > 1) if (params.size() > 1)
nCheckDepth = params[1].get_int(); nCheckDepth = params[1].get_int();
return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth); return CVerifyDB().VerifyDB(Params(), pcoinsTip, nCheckLevel, nCheckDepth);
} }
/** Implementation of IsSuperMajority with better feedback */ /** Implementation of IsSuperMajority with better feedback */
@ -828,7 +828,7 @@ UniValue invalidateblock(const UniValue& params, bool fHelp)
} }
if (state.IsValid()) { if (state.IsValid()) {
ActivateBestChain(state); ActivateBestChain(state, Params());
} }
if (!state.IsValid()) { if (!state.IsValid()) {
@ -867,7 +867,7 @@ UniValue reconsiderblock(const UniValue& params, bool fHelp)
} }
if (state.IsValid()) { if (state.IsValid()) {
ActivateBestChain(state); ActivateBestChain(state, Params());
} }
if (!state.IsValid()) { if (!state.IsValid()) {

3
src/test/test_bitcoin.cpp

@ -50,6 +50,7 @@ BasicTestingSetup::~BasicTestingSetup()
TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName) TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
{ {
const CChainParams& chainparams = Params();
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
bitdb.MakeMock(); bitdb.MakeMock();
#endif #endif
@ -60,7 +61,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
pblocktree = new CBlockTreeDB(1 << 20, true); pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true); pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(pcoinsdbview); pcoinsTip = new CCoinsViewCache(pcoinsdbview);
InitBlockIndex(); InitBlockIndex(chainparams);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
bool fFirstRun; bool fFirstRun;
pwalletMain = new CWallet("wallet.dat"); pwalletMain = new CWallet("wallet.dat");

Loading…
Cancel
Save