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.
This commit is contained in:
Pieter Wuille
2012-07-06 16:33:34 +02:00
parent 450cbb0944
commit ae8bfd12da
10 changed files with 183 additions and 171 deletions

View File

@@ -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"));