diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-07-06 16:33:34 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-10-20 23:08:57 +0200 |
commit | ae8bfd12daa802d20791e69d3477e799d2b99f45 (patch) | |
tree | 848867135da5954b7155ebe98c09db66d09d5737 /src/init.cpp | |
parent | 450cbb0944cd20a06ce806e6679a1f4c83c50db2 (diff) |
Batch block connection during IBD
During the initial block download (or -loadblock), delay connection
of new blocks a bit, and perform them in a single action. This reduces
the load on the database engine, as subsequent blocks often update an
earlier block's transaction already.
Diffstat (limited to 'src/init.cpp')
-rw-r--r-- | src/init.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp index 56108cecee..b05d57abfe 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -50,6 +50,8 @@ void StartShutdown() #endif } +static CCoinsViewDB *pcoinsdbview; + void Shutdown(void* parg) { static CCriticalSection cs_Shutdown; @@ -74,6 +76,12 @@ void Shutdown(void* parg) nTransactionsUpdated++; bitdb.Flush(false); StopNode(); + { + LOCK(cs_main); + pcoinsTip->Flush(); + delete pcoinsTip; + delete pcoinsdbview; + } bitdb.Flush(true); boost::filesystem::remove(GetPidFile()); UnregisterWallet(pwalletMain); @@ -298,6 +306,7 @@ std::string HelpMessage() return strUsage; } + /** Initialize bitcoin. * @pre Parameters should be parsed and config file should be read. */ @@ -641,6 +650,9 @@ bool AppInit2() 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")); |