// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include "txdb.h"
+#include "db.h"
#include "walletdb.h"
#include "bitcoinrpc.h"
#include "net.h"
std::string strWalletFileName;
unsigned int nNodeLifespan;
unsigned int nDerivationMethodIndex;
+unsigned int nMinerSleep;
+bool fUseFastIndex;
+bool fUseFastStakeMiner;
enum Checkpoints::CPMode CheckpointsMode;
//////////////////////////////////////////////////////////////////////////////
#endif
}
+static CCoinsViewDB *pcoinsdbview;
+
void Shutdown(void* parg)
{
static CCriticalSection cs_Shutdown;
{
fShutdown = true;
nTransactionsUpdated++;
-// CTxDB().Close();
bitdb.Flush(false);
StopNode();
+ {
+ LOCK(cs_main);
+ pcoinsTip->Flush();
+ delete pcoinsTip;
+ delete pcoinsdbview;
+ }
bitdb.Flush(true);
boost::filesystem::remove(GetPidFile());
UnregisterWallet(pwalletMain);
" -bind=<addr> " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" +
" -dnsseed " + _("Find peers using DNS lookup (default: 1)") + "\n" +
" -cppolicy " + _("Sync checkpoints policy (default: strict)") + "\n" +
- " -stakepooledkeys " + _("Use pooled pubkeys for the last coinstake output (default: 0)") + "\n" +
- " -derivationmethod " + _("Which key derivation method to use by default (default: sha512)") + "\n" +
" -banscore=<n> " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" +
" -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" +
" -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n" +
// ********************************************************* Step 2: parameter interactions
nNodeLifespan = GetArg("-addrlifespan", 7);
- fStakeUsePooledKeys = GetBoolArg("-stakepooledkeys", false);
+ fUseFastIndex = GetBoolArg("-fastindex", true);
+ nMinerSleep = GetArg("-minersleep", 500);
CheckpointsMode = Checkpoints::STRICT;
std::string strCpMode = GetArg("-cppolicy", "strict");
if(strCpMode == "permissive")
CheckpointsMode = Checkpoints::PERMISSIVE;
- if(GetArg("-derivationmethod", "sha512") == "scrypt+sha512")
- nDerivationMethodIndex = 1;
+ nDerivationMethodIndex = 0;
fTestNet = GetBoolArg("-testnet");
if (fTestNet) {
return InitError(msg);
}
- if (GetBoolArg("-loadblockindextest"))
- {
- CTxDB txdb("r");
- txdb.LoadBlockIndex();
- PrintBlockTree();
- return false;
- }
-
uiInterface.InitMessage(_("Loading block index..."));
printf("Loading block index...\n");
nStart = GetTimeMillis();
+ pcoinsdbview = new CCoinsViewDB();
+ pcoinsTip = new CCoinsViewCache(*pcoinsdbview);
+
if (!LoadBlockIndex())
return InitError(_("Error loading blkindex.dat"));
-
// as LoadBlockIndex can take several minutes, it's possible the user
// requested to kill bitcoin-qt during the last operation. If so, exit.
// As the program has not fully started yet, Shutdown() is possibly overkill.
// ********************************************************* Step 9: import blocks
+ // scan for better chains in the block chain database, that are not yet connected in the active best chain
+ CBlockIndex *pindexFoundBest = pindexBest;
+ for (std::map<uint256,CBlockIndex*>::iterator it = mapBlockIndex.begin(); it != mapBlockIndex.end(); it++) {
+ CBlockIndex *pindex = it->second;
+ if (pindexFoundBest==NULL || pindex->nChainTrust > pindexFoundBest->nChainTrust)
+ pindexFoundBest = pindex;
+ }
+ if (pindexFoundBest != pindexBest) {
+ uiInterface.InitMessage(_("Importing blocks from block database..."));
+ uint64 nTxs = 0;
+ uint64 nBlocks = 0;
+ std::vector<CBlockIndex*> vAttach;
+ vAttach.reserve(pindexFoundBest->nHeight - (pindexBest==NULL ? 0 : pindexBest->nHeight));
+ while (pindexFoundBest && pindexFoundBest->nChainTrust > (pindexBest==NULL ? 0 : pindexBest->nChainTrust)) {
+ vAttach.push_back(pindexFoundBest);
+ pindexFoundBest = pindexFoundBest->pprev;
+ }
+ for (std::vector<CBlockIndex*>::reverse_iterator it = vAttach.rbegin(); it != vAttach.rend(); it++) {
+ CBlockIndex *pindex = *it;
+ CBlock block;
+ if (!block.ReadFromDisk(pindex))
+ break;
+ nTxs += block.vtx.size();
+ nBlocks++;
+ if (pindex->nHeight == 0 || nTxs + nBlocks*3 > 500) {
+ nTxs=0;
+ nBlocks=0;
+ block.SetBestChain(pindex);
+ }
+ if (fRequestShutdown)
+ break;
+ }
+ }
+
if (mapArgs.count("-loadblock"))
{
uiInterface.InitMessage(_("Importing blockchain data file."));