Skip to content

Commit fa4d478

Browse files
author
MarcoFalke
committed
qt: Use nPowTargetSpacing constant
1 parent b250686 commit fa4d478

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/qt/bitcoingui.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "macdockiconhandler.h"
3232
#endif
3333

34+
#include "chainparams.h"
3435
#include "init.h"
3536
#include "ui_interface.h"
3637
#include "util.h"
@@ -752,8 +753,8 @@ void BitcoinGUI::updateHeadersSyncProgressLabel()
752753
{
753754
int64_t headersTipTime = clientModel->getHeaderTipTime();
754755
int headersTipHeight = clientModel->getHeaderTipHeight();
755-
int estHeadersLeft = (GetTime() - headersTipTime)/600;
756-
if (estHeadersLeft > REQ_HEADER_HEIGHT_DELTA_SYNC)
756+
int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetConsensus().nPowTargetSpacing;
757+
if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
757758
progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
758759
}
759760

src/qt/modaloverlay.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include "guiutil.h"
99

10+
#include "chainparams.h"
11+
1012
#include <QResizeEvent>
1113
#include <QPropertyAnimation>
1214

@@ -125,11 +127,11 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
125127

126128
// estimate the number of headers left based on nPowTargetSpacing
127129
// and check if the gui is not aware of the the best header (happens rarely)
128-
int estimateNumHeadersLeft = bestHeaderDate.secsTo(currentDate) / 600;
130+
int estimateNumHeadersLeft = bestHeaderDate.secsTo(currentDate) / Params().GetConsensus().nPowTargetSpacing;
129131
bool hasBestHeader = bestHeaderHeight >= count;
130132

131133
// show remaining number of blocks
132-
if (estimateNumHeadersLeft < 24 && hasBestHeader) {
134+
if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) {
133135
ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count));
134136
} else {
135137
ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1)...").arg(bestHeaderHeight));

src/qt/modaloverlay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <QWidget>
1010

1111
//! The required delta of headers to the estimated number of available headers until we show the IBD progress
12-
static const int REQ_HEADER_HEIGHT_DELTA_SYNC = 24;
12+
static constexpr int HEADER_HEIGHT_DELTA_SYNC = 24;
1313

1414
namespace Ui {
1515
class ModalOverlay;

src/qt/sendcoinsdialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "walletmodel.h"
1717

1818
#include "base58.h"
19+
#include "chainparams.h"
1920
#include "wallet/coincontrol.h"
2021
#include "validation.h" // mempool and minRelayTxFee
2122
#include "ui_interface.h"
@@ -608,7 +609,7 @@ void SendCoinsDialog::updateGlobalFeeVariables()
608609
CoinControlDialog::coinControl->nMinimumTotalFee = 0;
609610

610611
// show the estimated reuquired time for confirmation
611-
ui->confirmationTargetLabel->setText(GUIUtil::formatDurationStr(nConfirmTarget*600)+" / "+tr("%n block(s)", "", nConfirmTarget));
612+
ui->confirmationTargetLabel->setText(GUIUtil::formatDurationStr(nConfirmTarget * Params().GetConsensus().nPowTargetSpacing) + " / " + tr("%n block(s)", "", nConfirmTarget));
612613
}
613614
else
614615
{

0 commit comments

Comments
 (0)