23
23
24
24
#include < cmath>
25
25
26
- /* Total required space (in GB) depending on user choice (prune, not prune) */
27
- static int64_t requiredSpace;
28
-
29
26
/* Check free space asynchronously to prevent hanging the UI thread.
30
27
31
28
Up to one request to check a path is in flight to this thread; when the check()
@@ -111,21 +108,21 @@ void FreespaceChecker::check()
111
108
}
112
109
113
110
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 ) :
115
112
QDialog(parent),
116
113
ui(new Ui::Intro),
117
114
thread(nullptr ),
118
115
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 )
121
118
{
122
119
ui->setupUi (this );
123
120
ui->welcomeLabel ->setText (ui->welcomeLabel ->text ().arg (PACKAGE_NAME));
124
121
ui->storageLabel ->setText (ui->storageLabel ->text ().arg (PACKAGE_NAME));
125
122
126
123
ui->lblExplanation1 ->setText (ui->lblExplanation1 ->text ()
127
124
.arg (PACKAGE_NAME)
128
- .arg (m_blockchain_size )
125
+ .arg (m_blockchain_size_gb )
129
126
.arg (2009 )
130
127
.arg (tr (" Bitcoin" ))
131
128
);
@@ -138,21 +135,16 @@ Intro::Intro(QWidget *parent, uint64_t blockchain_size, uint64_t chain_state_siz
138
135
}
139
136
const int prune_target_gb = PruneMiBtoGB (prune_target_mib);
140
137
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 ;
142
139
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." );
151
143
}
152
- requiredSpace += m_chain_state_size ;
144
+ ui-> lblExplanation3 -> setVisible (prune_target_gb > 0 ) ;
153
145
ui->sizeWarningLabel ->setText (
154
146
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 ) + " " +
156
148
tr (" The wallet will also be stored in this directory." )
157
149
);
158
150
this ->adjustSize ();
@@ -272,13 +264,12 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
272
264
ui->freeSpace ->setText (" " );
273
265
} else {
274
266
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);
278
269
ui->freeSpace ->setStyleSheet (" QLabel { color: #800000 }" );
279
270
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 );
282
273
ui->freeSpace ->setStyleSheet (" QLabel { color: #999900 }" );
283
274
ui->prune ->setChecked (true );
284
275
} else {
0 commit comments