2323
2424#include < cmath>
2525
26- /* Total required space (in GB) depending on user choice (prune, not prune) */
27- static int64_t requiredSpace;
28-
2926/* Check free space asynchronously to prevent hanging the UI thread.
3027
3128 Up to one request to check a path is in flight to this thread; when the check()
@@ -111,21 +108,21 @@ void FreespaceChecker::check()
111108}
112109
113110
114- Intro::Intro (QWidget *parent, uint64_t blockchain_size, uint64_t chain_state_size ) :
111+ Intro::Intro (QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_size_gb ) :
115112 QDialog(parent),
116113 ui(new Ui::Intro),
117114 thread(nullptr ),
118115 signalled(false ),
119- m_blockchain_size(blockchain_size ),
120- m_chain_state_size(chain_state_size )
116+ m_blockchain_size_gb(blockchain_size_gb ),
117+ m_chain_state_size_gb(chain_state_size_gb )
121118{
122119 ui->setupUi (this );
123120 ui->welcomeLabel ->setText (ui->welcomeLabel ->text ().arg (PACKAGE_NAME));
124121 ui->storageLabel ->setText (ui->storageLabel ->text ().arg (PACKAGE_NAME));
125122
126123 ui->lblExplanation1 ->setText (ui->lblExplanation1 ->text ()
127124 .arg (PACKAGE_NAME)
128- .arg (m_blockchain_size )
125+ .arg (m_blockchain_size_gb )
129126 .arg (2009 )
130127 .arg (tr (" Bitcoin" ))
131128 );
@@ -138,21 +135,16 @@ Intro::Intro(QWidget *parent, uint64_t blockchain_size, uint64_t chain_state_siz
138135 }
139136 const int prune_target_gb = PruneMiBtoGB (prune_target_mib);
140137 ui->prune ->setText (tr (" Discard blocks after verification, except most recent %1 GB (prune)" ).arg (prune_target_gb ? prune_target_gb : DEFAULT_PRUNE_TARGET_GB));
141- requiredSpace = m_blockchain_size ;
138+ m_required_space_gb = m_blockchain_size_gb + m_chain_state_size_gb ;
142139 QString storageRequiresMsg = tr (" At least %1 GB of data will be stored in this directory, and it will grow over time." );
143- if (prune_target_gb) {
144- if (prune_target_gb <= requiredSpace) {
145- requiredSpace = prune_target_gb;
146- storageRequiresMsg = tr (" Approximately %1 GB of data will be stored in this directory." );
147- }
148- ui->lblExplanation3 ->setVisible (true );
149- } else {
150- ui->lblExplanation3 ->setVisible (false );
140+ if (0 < prune_target_gb && prune_target_gb <= m_blockchain_size_gb) {
141+ m_required_space_gb = prune_target_gb + m_chain_state_size_gb;
142+ storageRequiresMsg = tr (" Approximately %1 GB of data will be stored in this directory." );
151143 }
152- requiredSpace += m_chain_state_size ;
144+ ui-> lblExplanation3 -> setVisible (prune_target_gb > 0 ) ;
153145 ui->sizeWarningLabel ->setText (
154146 tr (" %1 will download and store a copy of the Bitcoin block chain." ).arg (PACKAGE_NAME) + " " +
155- storageRequiresMsg.arg (requiredSpace ) + " " +
147+ storageRequiresMsg.arg (m_required_space_gb ) + " " +
156148 tr (" The wallet will also be stored in this directory." )
157149 );
158150 this ->adjustSize ();
@@ -272,13 +264,12 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
272264 ui->freeSpace ->setText (" " );
273265 } else {
274266 QString freeString = tr (" %n GB of free space available" , " " , bytesAvailable/GB_BYTES);
275- if (bytesAvailable < requiredSpace * GB_BYTES)
276- {
277- freeString += " " + tr (" (of %n GB needed)" , " " , requiredSpace);
267+ if (bytesAvailable < m_required_space_gb * GB_BYTES) {
268+ freeString += " " + tr (" (of %n GB needed)" , " " , m_required_space_gb);
278269 ui->freeSpace ->setStyleSheet (" QLabel { color: #800000 }" );
279270 ui->prune ->setChecked (true );
280- } else if (bytesAvailable / GB_BYTES - requiredSpace < 10 ) {
281- freeString += " " + tr (" (%n GB needed for full chain)" , " " , requiredSpace );
271+ } else if (bytesAvailable / GB_BYTES - m_required_space_gb < 10 ) {
272+ freeString += " " + tr (" (%n GB needed for full chain)" , " " , m_required_space_gb );
282273 ui->freeSpace ->setStyleSheet (" QLabel { color: #999900 }" );
283274 ui->prune ->setChecked (true );
284275 } else {
0 commit comments