-
Notifications
You must be signed in to change notification settings - Fork 304
Enable changing the autoprune block space size in intro dialog #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
62932cc
f2e5a6b
e2dcd95
2a84c6b
415fb2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -7,7 +7,7 @@ | |||||||||||||||||||||||||
<x>0</x> | ||||||||||||||||||||||||||
<y>0</y> | ||||||||||||||||||||||||||
<width>674</width> | ||||||||||||||||||||||||||
<height>415</height> | ||||||||||||||||||||||||||
<height>447</height> | ||||||||||||||||||||||||||
</rect> | ||||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
<property name="windowTitle"> | ||||||||||||||||||||||||||
|
@@ -210,16 +210,6 @@ | |||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
</widget> | ||||||||||||||||||||||||||
</item> | ||||||||||||||||||||||||||
<item> | ||||||||||||||||||||||||||
<widget class="QCheckBox" name="prune"> | ||||||||||||||||||||||||||
<property name="toolTip"> | ||||||||||||||||||||||||||
<string>Reverting this setting requires re-downloading the entire blockchain. It is faster to download the full chain first and prune it later. Disables some advanced features.</string> | ||||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
<property name="text"> | ||||||||||||||||||||||||||
<string></string> | ||||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
</widget> | ||||||||||||||||||||||||||
</item> | ||||||||||||||||||||||||||
<item> | ||||||||||||||||||||||||||
<widget class="QLabel" name="lblExplanation2"> | ||||||||||||||||||||||||||
<property name="text"> | ||||||||||||||||||||||||||
|
@@ -240,6 +230,47 @@ | |||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
</widget> | ||||||||||||||||||||||||||
</item> | ||||||||||||||||||||||||||
<item> | ||||||||||||||||||||||||||
<layout class="QHBoxLayout" name="pruneOptLayout"> | ||||||||||||||||||||||||||
<item> | ||||||||||||||||||||||||||
<widget class="QCheckBox" name="prune"> | ||||||||||||||||||||||||||
<property name="text"> | ||||||||||||||||||||||||||
<string>Limit block chain storage to</string> | ||||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
<property name="toolTip"> | ||||||||||||||||||||||||||
<string>Reverting this setting requires re-downloading the entire blockchain. It is faster to download the full chain first and prune it later. Disables some advanced features.</string> | ||||||||||||||||||||||||||
luke-jr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
Comment on lines
+237
to
+242
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Qt Designer insists on changing properties order:
Suggested change
|
||||||||||||||||||||||||||
</widget> | ||||||||||||||||||||||||||
</item> | ||||||||||||||||||||||||||
<item> | ||||||||||||||||||||||||||
<widget class="QSpinBox" name="pruneGB"> | ||||||||||||||||||||||||||
<property name="suffix"> | ||||||||||||||||||||||||||
<string> GB</string> | ||||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
</widget> | ||||||||||||||||||||||||||
</item> | ||||||||||||||||||||||||||
<item> | ||||||||||||||||||||||||||
<widget class="QLabel" name="lblPruneSuffix"> | ||||||||||||||||||||||||||
<property name="buddy"> | ||||||||||||||||||||||||||
<cstring>pruneGB</cstring> | ||||||||||||||||||||||||||
</property> | ||||||||||||||||||||||||||
luke-jr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
</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> | ||||||||||||||||||||||||||
<spacer name="verticalSpacer"> | ||||||||||||||||||||||||||
<property name="orientation"> | ||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,6 +17,7 @@ | |||||||||||||
|
||||||||||||||
#include <interfaces/node.h> | ||||||||||||||
#include <util/system.h> | ||||||||||||||
#include <validation.h> | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's unfortunate to include this just because of |
||||||||||||||
|
||||||||||||||
#include <QFileDialog> | ||||||||||||||
#include <QSettings> | ||||||||||||||
|
@@ -139,17 +140,26 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si | |||||||||||||
); | ||||||||||||||
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(PACKAGE_NAME)); | ||||||||||||||
|
||||||||||||||
const int min_prune_target_GB = std::ceil(MIN_DISK_SPACE_FOR_BLOCK_FILES / 1e9); | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: why here and after not use Lines 52 to 53 in fa2a5b8
? |
||||||||||||||
ui->pruneGB->setRange(min_prune_target_GB, std::numeric_limits<int>::max()); | ||||||||||||||
if (gArgs.GetArg("-prune", 0) > 1) { // -prune=1 means enabled, above that it's a size in MiB | ||||||||||||||
ui->prune->setChecked(true); | ||||||||||||||
ui->prune->setEnabled(false); | ||||||||||||||
} | ||||||||||||||
ui->prune->setText(tr("Discard blocks after verification, except most recent %1 GB (prune)").arg(m_prune_target_gb)); | ||||||||||||||
ui->pruneGB->setValue(m_prune_target_gb); | ||||||||||||||
ui->pruneGB->setToolTip(ui->prune->toolTip()); | ||||||||||||||
ui->lblPruneSuffix->setToolTip(ui->prune->toolTip()); | ||||||||||||||
UpdatePruneLabels(ui->prune->isChecked()); | ||||||||||||||
|
||||||||||||||
connect(ui->prune, &QCheckBox::toggled, [this](bool prune_checked) { | ||||||||||||||
UpdatePruneLabels(prune_checked); | ||||||||||||||
UpdateFreeSpaceLabel(); | ||||||||||||||
}); | ||||||||||||||
connect(ui->pruneGB, QOverload<int>::of(&QSpinBox::valueChanged), [this](int prune_GB) { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC qOverload function template does not work with Visual Studio 2017 due to implementation limitations, and I see that compiler mentioned in https://github.com/bitcoin-core/gui/blob/master/build_msvc/README.md . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oh, I was not aware of it. I'd like to know more about this pitfall. Any proof/link/test is appreciated :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Since bitcoin/bitcoin#21811 is merged, it isn't a problem, is it? Btw, could you look at #257? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seem so, yes. Maybe I should try building on some older GCC to make sure other compiler does not have similar limitations (though I doubt it). I will take a look at 257 at some time. |
||||||||||||||
m_prune_target_gb = prune_GB; | ||||||||||||||
UpdatePruneLabels(ui->prune->isChecked()); | ||||||||||||||
UpdateFreeSpaceLabel(); | ||||||||||||||
}); | ||||||||||||||
|
||||||||||||||
startThread(); | ||||||||||||||
} | ||||||||||||||
|
@@ -182,7 +192,17 @@ void Intro::setDataDirectory(const QString &dataDir) | |||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
bool Intro::showIfNeeded(bool& did_show_intro, bool& prune) | ||||||||||||||
int64_t Intro::getPruneMiB() const | ||||||||||||||
{ | ||||||||||||||
switch (ui->prune->checkState()) { | ||||||||||||||
case Qt::Checked: | ||||||||||||||
return PruneGBtoMiB(m_prune_target_gb); | ||||||||||||||
case Qt::Unchecked: default: | ||||||||||||||
return 0; | ||||||||||||||
Comment on lines
+200
to
+201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
} | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB) | ||||||||||||||
{ | ||||||||||||||
did_show_intro = false; | ||||||||||||||
|
||||||||||||||
|
@@ -233,7 +253,7 @@ bool Intro::showIfNeeded(bool& did_show_intro, bool& prune) | |||||||||||||
} | ||||||||||||||
|
||||||||||||||
// Additional preferences: | ||||||||||||||
prune = intro.ui->prune->isChecked(); | ||||||||||||||
prune_MiB = intro.getPruneMiB(); | ||||||||||||||
|
||||||||||||||
settings.setValue("strDataDir", dataDir); | ||||||||||||||
settings.setValue("fReset", false); | ||||||||||||||
|
@@ -361,6 +381,11 @@ void Intro::UpdatePruneLabels(bool prune_checked) | |||||||||||||
storageRequiresMsg = tr("Approximately %1 GB of data will be stored in this directory."); | ||||||||||||||
} | ||||||||||||||
ui->lblExplanation3->setVisible(prune_checked); | ||||||||||||||
ui->pruneGB->setEnabled(prune_checked); | ||||||||||||||
static constexpr uint64_t nPowTargetSpacing = 10 * 60; // from chainparams, which we don't have at this stage | ||||||||||||||
static constexpr uint32_t expected_block_data_size = 2250000; // includes undo data | ||||||||||||||
Comment on lines
+385
to
+386
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style piconit:
Suggested change
|
||||||||||||||
const uint64_t expected_backup_days = m_prune_target_gb * 1e9 / (uint64_t(expected_block_data_size) * 86400 / nPowTargetSpacing); | ||||||||||||||
ui->lblPruneSuffix->setText(tr("(sufficient to restore backups %n day(s) old)", "block chain pruning", expected_backup_days)); | ||||||||||||||
ui->sizeWarningLabel->setText( | ||||||||||||||
tr("%1 will download and store a copy of the Bitcoin block chain.").arg(PACKAGE_NAME) + " " + | ||||||||||||||
storageRequiresMsg.arg(m_required_space_gb) + " " + | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ class Intro : public QDialog | |
|
||
QString getDataDirectory(); | ||
void setDataDirectory(const QString &dataDir); | ||
int64_t getPruneMiB() const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be private? |
||
|
||
/** | ||
* Determine data directory. Let the user choose if the current one doesn't exist. | ||
|
@@ -47,7 +48,7 @@ class Intro : public QDialog | |
* @note do NOT call global GetDataDir() before calling this function, this | ||
* will cause the wrong path to be cached. | ||
*/ | ||
static bool showIfNeeded(bool& did_show_intro, bool& prune); | ||
static bool showIfNeeded(bool& did_show_intro, int64_t& prune_MiB); | ||
|
||
Q_SIGNALS: | ||
void requestCheck(); | ||
|
@@ -72,7 +73,7 @@ private Q_SLOTS: | |
//! Total required space (in GB) depending on user choice (prune or not prune). | ||
int64_t m_required_space_gb{0}; | ||
uint64_t m_bytes_available{0}; | ||
const int64_t m_prune_target_gb; | ||
int64_t m_prune_target_gb; | ||
|
||
void startThread(); | ||
void checkPath(const QString &dataDir); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style piconit:
clang-format-diff.py
suggests