aboutsummaryrefslogtreecommitdiff
path: root/src/init.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-01-17 16:58:58 -0800
committerGavin Andresen <gavinandresen@gmail.com>2013-01-17 16:58:58 -0800
commit0e31ae9818528d52bbd802a8917b7015f8e38ae7 (patch)
tree75259fd38459f852cc5b2a97fc91e93399e114c5 /src/init.cpp
parent91f70a75daa7ffb89bbec23ca54e5f2c3fa1a83e (diff)
parentef0f422519de4a3ce47d923e5f8f90cd12349f3e (diff)
downloadbitcoin-0e31ae9818528d52bbd802a8917b7015f8e38ae7.tar.xz
Merge pull request #2060 from sipa/parallel
Parallel script verification
Diffstat (limited to 'src/init.cpp')
-rw-r--r--src/init.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index a9297c5a12..4f319e8cbf 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -84,6 +84,10 @@ void Shutdown(void* parg)
fShutdown = true;
nTransactionsUpdated++;
bitdb.Flush(false);
+ {
+ LOCK(cs_main);
+ ThreadScriptCheckQuit();
+ }
StopNode();
{
LOCK(cs_main);
@@ -303,6 +307,7 @@ std::string HelpMessage()
" -checklevel=<n> " + _("How thorough the block verification is (0-4, default: 3)") + "\n" +
" -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + "\n" +
" -reindex " + _("Rebuild blockchain index from current blk000??.dat files") + "\n" +
+ " -par=N " + _("Set the number of script verification threads (1-16, 0=auto, default: 0)") + "\n" +
"\n" + _("Block creation options:") + "\n" +
" -blockminsize=<n> " + _("Set minimum block size in bytes (default: 0)") + "\n" +
@@ -484,6 +489,15 @@ bool AppInit2()
fDebug = GetBoolArg("-debug");
fBenchmark = GetBoolArg("-benchmark");
+ // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
+ nScriptCheckThreads = GetArg("-par", 0);
+ if (nScriptCheckThreads == 0)
+ nScriptCheckThreads = boost::thread::hardware_concurrency();
+ if (nScriptCheckThreads <= 1)
+ nScriptCheckThreads = 0;
+ else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS)
+ nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS;
+
// -debug implies fDebug*
if (fDebug)
fDebugNet = true;
@@ -579,6 +593,12 @@ bool AppInit2()
if (fDaemon)
fprintf(stdout, "Bitcoin server starting\n");
+ if (nScriptCheckThreads) {
+ printf("Using %u threads for script verification\n", nScriptCheckThreads);
+ for (int i=0; i<nScriptCheckThreads-1; i++)
+ NewThread(ThreadScriptCheck, NULL);
+ }
+
int64 nStart;
// ********************************************************* Step 5: verify wallet database integrity