mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
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:
12
src/init.cpp
12
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"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user