diff options
| author | Pieter Wuille <[email protected]> | 2012-10-20 14:49:33 -0700 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2012-10-20 14:49:33 -0700 |
| commit | cf9b49fa50f439e57896ce2c176214052833a09a (patch) | |
| tree | 7c0df7313bf492b67bd629a01d28074f22af4104 /src/init.cpp | |
| parent | Merge pull request #1880 from sipa/threadimport (diff) | |
| parent | Remove BDB block database support (diff) | |
| download | discoin-cf9b49fa50f439e57896ce2c176214052833a09a.tar.xz discoin-cf9b49fa50f439e57896ce2c176214052833a09a.zip | |
Merge pull request #1677 from sipa/ultraprune
Ultraprune: use a pruned-txout-set database for block validation
Diffstat (limited to 'src/init.cpp')
| -rw-r--r-- | src/init.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/src/init.cpp b/src/init.cpp index 92c752a8f..4d5720306 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2,7 +2,7 @@ // 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 "db.h" +#include "txdb.h" #include "walletdb.h" #include "bitcoinrpc.h" #include "net.h" @@ -50,6 +50,8 @@ void StartShutdown() #endif } +static CCoinsViewDB *pcoinsdbview; + void Shutdown(void* parg) { static CCriticalSection cs_Shutdown; @@ -74,6 +76,14 @@ void Shutdown(void* parg) nTransactionsUpdated++; bitdb.Flush(false); StopNode(); + { + LOCK(cs_main); + pcoinsTip->Flush(); + pblocktree->Flush(); + delete pcoinsTip; + delete pcoinsdbview; + delete pblocktree; + } bitdb.Flush(true); boost::filesystem::remove(GetPidFile()); UnregisterWallet(pwalletMain); @@ -298,6 +308,7 @@ std::string HelpMessage() return strUsage; } + /** Initialize bitcoin. * @pre Parameters should be parsed and config file should be read. */ @@ -638,17 +649,13 @@ bool AppInit2() 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(); + pblocktree = new CBlockTreeDB(); + pcoinsdbview = new CCoinsViewDB(); + pcoinsTip = new CCoinsViewCache(*pcoinsdbview); + if (!LoadBlockIndex()) return InitError(_("Error loading blkindex.dat")); @@ -776,6 +783,11 @@ bool AppInit2() // ********************************************************* Step 9: import blocks + // scan for better chains in the block chain database, that are not yet connected in the active best chain + uiInterface.InitMessage(_("Importing blocks from block database...")); + if (!ConnectBestBlock()) + strErrors << "Failed to connect best block"; + std::vector<boost::filesystem::path> *vPath = new std::vector<boost::filesystem::path>(); if (mapArgs.count("-loadblock")) { |