From ae8bfd12daa802d20791e69d3477e799d2b99f45 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 6 Jul 2012 16:33:34 +0200 Subject: 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. --- src/init.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index 56108cece..b05d57abf 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")); -- cgit v1.2.3