From 79a331b05cf5a31bf087c0a1719d51e9596ea53d Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Tue, 18 Feb 2014 12:48:16 +0100 Subject: [PATCH] add constant for shared GUI core par settings. --- src/init.cpp | 4 ++-- src/main.h | 7 +++++++ src/qt/forms/optionsdialog.ui | 8 +------- src/qt/optionsdialog.cpp | 4 +++- src/qt/optionsmodel.cpp | 21 +++++++++++---------- 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 4773fe101..1350f6e5a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -210,7 +210,7 @@ std::string HelpMessage(HelpMessageMode hmm) strUsage += " -dbcache= " + strprintf(_("Set database cache size in megabytes (%d to %d, default: %d)"), nMinDbCache, nMaxDbCache, nDefaultDbCache) + "\n"; strUsage += " -keypool= " + _("Set key pool size to (default: 100)") + "\n"; strUsage += " -loadblock= " + _("Imports blocks from external blk000??.dat file") + " " + _("on startup") + "\n"; - strUsage += " -par= " + _("Set the number of script verification threads (up to 16, 0 = auto, <0 = leave that many cores free, default: 0)") + "\n"; + strUsage += " -par= " + strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"), -(int)boost::thread::hardware_concurrency(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS) + "\n"; strUsage += " -pid= " + _("Specify pid file (default: dogecoind.pid)") + "\n"; strUsage += " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + " " + _("on startup") + "\n"; strUsage += " -txindex " + _("Maintain a full transaction index (default: 0)") + "\n"; @@ -529,7 +529,7 @@ bool AppInit2(boost::thread_group& threadGroup) Checkpoints::fEnabled = GetBoolArg("-checkpoints", true); // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency - nScriptCheckThreads = GetArg("-par", 0); + nScriptCheckThreads = GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS); if (nScriptCheckThreads <= 0) nScriptCheckThreads += boost::thread::hardware_concurrency(); if (nScriptCheckThreads <= 1) diff --git a/src/main.h b/src/main.h index a49526f39..c8a6a9842 100644 --- a/src/main.h +++ b/src/main.h @@ -72,6 +72,13 @@ static const int COINBASE_MATURITY_SWITCH = 145000; static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC /** Maximum number of script-checking threads allowed */ static const int MAX_SCRIPTCHECK_THREADS = 16; +/** -par default (number of script-checking threads, 0 = auto) */ +static const int DEFAULT_SCRIPTCHECK_THREADS = 0; +/** Number of blocks that can be requested at any given time from a single peer. */ +static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 128; +/** Timeout in seconds before considering a block download peer unresponsive. */ +static const unsigned int BLOCK_DOWNLOAD_TIMEOUT = 60; + #ifdef USE_UPNP static const int fHaveUPnP = true; #else diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index b5e4c4914..62390f406 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -98,13 +98,7 @@ - Set the number of script verification threads (up to 16, 0 = auto, <0 = leave that many cores free, default: 0) - - - -16 - - - 16 + (0 = auto, <0 = leave that many cores free) diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index a02c07dd7..62826d885 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -14,7 +14,7 @@ #include "monitoreddatamapper.h" #include "optionsmodel.h" -#include "main.h" // for CTransaction::nMinTxFee +#include "main.h" // for CTransaction::nMinTxFee and MAX_SCRIPTCHECK_THREADS #include "netbase.h" #include "txdb.h" // for -dbcache defaults @@ -37,6 +37,8 @@ OptionsDialog::OptionsDialog(QWidget *parent) : /* Main elements init */ ui->databaseCache->setMinimum(nMinDbCache); ui->databaseCache->setMaximum(nMaxDbCache); + ui->threadsScriptVerif->setMinimum(-(int)boost::thread::hardware_concurrency()); + ui->threadsScriptVerif->setMaximum(MAX_SCRIPTCHECK_THREADS); /* Network elements init */ #ifndef USE_UPNP diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 352db166d..16793afc4 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -78,6 +78,17 @@ void OptionsModel::Init() // by command-line and show this in the UI. // Main + if (!settings.contains("nDatabaseCache")) + settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache); + if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString())) + addOverriddenOption("-dbcache"); + + if (!settings.contains("nThreadsScriptVerif")) + settings.setValue("nThreadsScriptVerif", DEFAULT_SCRIPTCHECK_THREADS); + if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString())) + addOverriddenOption("-par"); + + // Wallet #ifdef ENABLE_WALLET if (!settings.contains("nTransactionFee")) settings.setValue("nTransactionFee", 0); @@ -91,16 +102,6 @@ void OptionsModel::Init() addOverriddenOption("-spendzeroconfchange"); #endif - if (!settings.contains("nDatabaseCache")) - settings.setValue("nDatabaseCache", (qint64)nDefaultDbCache); - if (!SoftSetArg("-dbcache", settings.value("nDatabaseCache").toString().toStdString())) - addOverriddenOption("-dbcache"); - - if (!settings.contains("nThreadsScriptVerif")) - settings.setValue("nThreadsScriptVerif", 0); - if (!SoftSetArg("-par", settings.value("nThreadsScriptVerif").toString().toStdString())) - addOverriddenOption("-par"); - // Network if (!settings.contains("fUseUPnP")) #ifdef USE_UPNP