Skip to content
Permalink
Browse files

Merge rwconf_policy-0.16+knots

  • Loading branch information...
luke-jr committed Jul 21, 2018
3 parents 99aae25 + 98d2b90 + f1d39ca commit e4d1059638cf8a9ecb949e3c5d2191f770bff6b5
@@ -72,6 +72,7 @@
#endif

bool fFeeEstimatesInitialized = false;
static const bool DEFAULT_COREPOLICY = false;
static const bool DEFAULT_PROXYRANDOMIZE = true;
static const bool DEFAULT_REST_ENABLE = false;
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
@@ -350,6 +351,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage +=HelpMessageOpt("-assumevalid=<hex>", strprintf(_("If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: %s, testnet: %s)"), defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), testnetChainParams->GetConsensus().defaultAssumeValid.GetHex()));
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), BITCOIN_CONF_FILENAME));
strUsage += HelpMessageOpt("-confrw=<file>", strprintf(_("Specify read/write configuration file (default: %s)"), BITCOIN_RW_CONF_FILENAME));
strUsage += HelpMessageOpt("-corepolicy", strprintf(_("Use Bitcoin Core policy defaults (default: %s)"), DEFAULT_COREPOLICY));
if (mode == HMM_BITCOIND)
{
#if HAVE_DECL_DAEMON
@@ -778,6 +780,17 @@ bool AppInitServers()
// Parameter interaction based on rules
void InitParameterInteraction()
{
if (gArgs.GetBoolArg("-corepolicy", DEFAULT_COREPOLICY)) {
gArgs.SoftSetArg("-bytespersigopstrict", "0");
gArgs.SoftSetArg("-permitbaremultisig", "1");
gArgs.SoftSetArg("-datacarriersize", "83");

gArgs.SoftSetArg("-spkreuse", "allow");
gArgs.SoftSetArg("-blockprioritysize", "0");
gArgs.SoftSetArg("-blockmaxsize", "4000000");
gArgs.SoftSetArg("-blockmaxweight", "3996000");
}

// when specifying an explicit binding address, you want to listen on it
// even when -connect or -proxy is specified
if (gArgs.IsArgSet("-bind")) {
@@ -1046,7 +1059,7 @@ bool AppInitParameterInteraction()

// mempool limits
int64_t nMempoolSizeMax = gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
int64_t nMempoolSizeMin = gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
int64_t nMempoolSizeMin = maxmempoolMinimum(gArgs.GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT)) * 1000000;
if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
// incremental relay fee sets the minimum feerate increase necessary for BIP 125 replacement in the mempool
@@ -7,9 +7,13 @@
#define BITCOIN_NET_PROCESSING_H

#include <net.h>
#include <sync.h>
#include <threadsafety.h>
#include <validationinterface.h>
#include <consensus/params.h>

extern CCriticalSection cs_main;

/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
/** Expiration time for orphan transactions in seconds */
@@ -83,6 +87,7 @@ struct CNodeStateStats {

/** Get statistics from node state */
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats);
unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/** Increase a node's misbehavior score. */
void Misbehaving(NodeId nodeid, int howmuch);

@@ -18,13 +18,13 @@ class CCoinsViewCache;
class CTxOut;

/** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = MAX_BLOCK_SERIALIZED_SIZE;
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 500000;
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0;
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 100000;
/** Minimum priority for transactions to be accepted into the priority area **/
static const double MINIMUM_TX_PRIORITY = COIN * 144 / 250;
/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/
static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = MAX_BLOCK_WEIGHT - 4000;
static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = 3000000;
/** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/
static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000;
/** The maximum weight for transactions we're willing to relay/mine */
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>674</width>
<height>415</height>
<height>447</height>
</rect>
</property>
<property name="windowTitle">
@@ -200,6 +200,40 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="chkPrune">
<property name="text">
<string>Limit block chain storage to</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="pruneMiB"/>
</item>
<item>
<widget class="QLabel" name="lblPruneSuffix">
<property name="buddy">
<cstring>pruneMiB</cstring>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="lblExplanation1">
<property name="text">
@@ -12,7 +12,9 @@

#include <qt/guiutil.h>

#include <consensus/consensus.h>
#include <util.h>
#include <validation.h>

#include <QFileDialog>
#include <QSettings>
@@ -131,26 +133,56 @@ Intro::Intro(QWidget *parent) :
);
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(tr(PACKAGE_NAME)));

uint64_t pruneTarget = std::max<int64_t>(0, gArgs.GetArg("-prune", 0));
int minPruneTarget = std::ceil(MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024.0 / 1024.0);
ui->pruneMiB->setMinimum(minPruneTarget);
ui->pruneMiB->setMaximum(std::numeric_limits<int>::max());

int64_t pruneTarget = gArgs.GetArg("-prune", 0);
if (pruneTarget > 1) {
ui->chkPrune->setChecked(true);
ui->pruneMiB->setValue(pruneTarget);
} else {
ui->chkPrune->setChecked(false);
ui->pruneMiB->setValue(minPruneTarget);
}
connect(ui->chkPrune, SIGNAL(stateChanged(int)), this, SLOT(UpdateText()));
connect(ui->pruneMiB, SIGNAL(valueChanged(int)), this, SLOT(UpdateText()));

UpdateText();

startThread();
}

void Intro::UpdateText()
{
requiredSpace = BLOCK_CHAIN_SIZE;
QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time.");
if (pruneTarget) {
uint64_t prunedGBs = std::ceil(pruneTarget * 1024 * 1024.0 / GB_BYTES);
uint64_t pruneBytes = uint64_t(ui->pruneMiB->value()) * 1024 * 1024;
if (ui->chkPrune->isChecked()) {
uint64_t prunedGBs = std::ceil(double(pruneBytes) / GB_BYTES);
if (prunedGBs <= requiredSpace) {
requiredSpace = prunedGBs;
storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory.");
ui->lblExplanation3->setVisible(true);
} else {
ui->lblExplanation3->setVisible(false);
}
ui->lblExplanation3->setVisible(true);
ui->pruneMiB->setEnabled(true);
} else {
ui->lblExplanation3->setVisible(false);
ui->pruneMiB->setEnabled(false);
}
static const uint64_t nPowTargetSpacing = 10 * 60; // from chainparams, which we don't have at this stage
// TODO: Bump this to 2-3 MB after segwit activates, based on real world changes
static const uint32_t nExpectedBlockDataSize = 1125000; // includes undo data
ui->lblPruneSuffix->setText(tr("MiB (sufficient to restore backups %n day(s) old)", "block chain pruning", pruneBytes / (uint64_t(nExpectedBlockDataSize) * 86400 / nPowTargetSpacing)));
requiredSpace += CHAIN_STATE_SIZE;
ui->sizeWarningLabel->setText(
tr("%1 will download and store a copy of the Bitcoin block chain.").arg(tr(PACKAGE_NAME)) + " " +
storageRequiresMsg.arg(requiredSpace) + " " +
tr("The wallet will also be stored in this directory.")
);
startThread();
Q_EMIT requestCheck();
}

Intro::~Intro()
@@ -181,6 +213,15 @@ void Intro::setDataDirectory(const QString &dataDir)
}
}

uint64_t Intro::getPrune()
{
if (ui->chkPrune->isChecked()) {
return ui->pruneMiB->value();
} else {
return 0;
}
}

QString Intro::getDefaultDataDirectory()
{
return GUIUtil::boostPathToQString(GetDefaultDataDir());
@@ -200,6 +241,8 @@ bool Intro::pickDataDirectory()

if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || settings.value("fReset", false).toBool() || gArgs.GetBoolArg("-resetguisettings", false))
{
int64_t introPrune;

/* If current default data directory does not exist, let the user choose one */
Intro intro;
intro.setDataDirectory(dataDir);
@@ -212,6 +255,7 @@ bool Intro::pickDataDirectory()
/* Cancel clicked */
return false;
}
introPrune = intro.getPrune();
dataDir = intro.getDataDirectory();
try {
if (TryCreateDirectories(GUIUtil::qstringToBoostPath(dataDir))) {
@@ -228,6 +272,13 @@ bool Intro::pickDataDirectory()

settings.setValue("strDataDir", dataDir);
settings.setValue("fReset", false);

if (introPrune || gArgs.GetArg("-prune", 0) > 1) {
// Initialise specified prune setting
std::string strPrune = strprintf("%d", introPrune);
gArgs.ForceSetArg("-prune", strPrune);
gArgs.ModifyRWConfigFile("prune", strPrune);
}
}
/* Only override -datadir if different from the default, to make it possible to
* override -datadir in the bitcoin.conf file in the default data directory
@@ -31,6 +31,7 @@ class Intro : public QDialog

QString getDataDirectory();
void setDataDirectory(const QString &dataDir);
uint64_t getPrune();

/**
* Determine data directory. Let the user choose if the current one doesn't exist.
@@ -60,6 +61,7 @@ private Q_SLOTS:
void on_ellipsisButton_clicked();
void on_dataDirDefault_clicked();
void on_dataDirCustom_clicked();
void UpdateText();

private:
Ui::Intro *ui;
Oops, something went wrong.

0 comments on commit e4d1059

Please sign in to comment.
You can’t perform that action at this time.