Skip to content

Commit f6bb1b1

Browse files
committed
qml: set synced to whether node is in IBD or not
This changes when we consider to be synced within the block clock's perspective from a check on if verificationProgress is large enough to a query on the node to see if it is in ibd or not
1 parent 8df54fe commit f6bb1b1

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/qml/components/BlockClock.qml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Item {
2424
property alias subText: subText.text
2525
property int headerSize: 32
2626
property bool connected: nodeModel.numOutboundPeers > 0
27-
property bool synced: nodeModel.verificationProgress > 0.999
27+
property bool synced: !nodeModel.inIBD
2828
property string syncProgress: formatProgressPercentage(nodeModel.verificationProgress * 100)
2929
property bool paused: false
3030
property var syncState: formatRemainingSyncTime(nodeModel.remainingSyncTime)
@@ -49,7 +49,7 @@ Item {
4949
verificationProgress: nodeModel.verificationProgress
5050
paused: root.paused
5151
connected: root.connected
52-
synced: nodeModel.verificationProgress > 0.999
52+
synced: root.synced
5353
backgroundColor: Theme.color.neutral2
5454
timeTickColor: Theme.color.neutral5
5555
confirmationColors: Theme.color.confirmationColors

src/qml/models/nodemodel.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ void NodeModel::setBlockTipHeight(int new_height)
3232
}
3333
}
3434

35+
36+
void NodeModel::setInIBD(bool new_ibd)
37+
{
38+
if (new_ibd != m_in_ibd) {
39+
m_in_ibd = new_ibd;
40+
Q_EMIT inIBDChanged();
41+
}
42+
}
43+
3544
void NodeModel::setNumOutboundPeers(int new_num)
3645
{
3746
if (new_num != m_num_outbound_peers) {
@@ -188,6 +197,7 @@ void NodeModel::ConnectToBlockTipSignal()
188197
[this](SynchronizationState state, interfaces::BlockTip tip, double verification_progress) {
189198
QMetaObject::invokeMethod(this, [=] {
190199
setBlockTipHeight(tip.block_height);
200+
setInIBD(m_node.isInitialBlockDownload());
191201
setVerificationProgress(verification_progress);
192202
setInHeaderSync(false);
193203
setInPreHeaderSync(false);
@@ -202,6 +212,7 @@ void NodeModel::ConnectToHeaderTipSignal()
202212

203213
m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(
204214
[this](SynchronizationState sync_state, interfaces::BlockTip tip, bool presync) {
215+
setInIBD(m_node.isInitialBlockDownload());
205216
QMetaObject::invokeMethod(this, [=] {
206217
if (presync) {
207218
setInHeaderSync(false);

src/qml/models/nodemodel.h

+5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class NodeModel : public QObject
2828
Q_OBJECT
2929
Q_PROPERTY(int blockTipHeight READ blockTipHeight NOTIFY blockTipHeightChanged)
3030
Q_PROPERTY(QString fullClientVersion READ fullClientVersion CONSTANT)
31+
Q_PROPERTY(bool inIBD READ inIBD NOTIFY inIBDChanged)
3132
Q_PROPERTY(int numOutboundPeers READ numOutboundPeers NOTIFY numOutboundPeersChanged)
3233
Q_PROPERTY(int maxNumOutboundPeers READ maxNumOutboundPeers CONSTANT)
3334
Q_PROPERTY(bool inHeaderSync READ inHeaderSync WRITE setInHeaderSync NOTIFY inHeaderSyncChanged)
@@ -44,6 +45,8 @@ class NodeModel : public QObject
4445
int blockTipHeight() const { return m_block_tip_height; }
4546
void setBlockTipHeight(int new_height);
4647
QString fullClientVersion() const { return QString::fromStdString(FormatFullVersion()); }
48+
bool inIBD() const { return m_in_ibd; }
49+
void setInIBD(bool new_ibd);
4750
int numOutboundPeers() const { return m_num_outbound_peers; }
4851
void setNumOutboundPeers(int new_num);
4952
int maxNumOutboundPeers() const { return m_max_num_outbound_peers; }
@@ -76,6 +79,7 @@ public Q_SLOTS:
7679

7780
Q_SIGNALS:
7881
void blockTipHeightChanged();
82+
void inIBDChanged();
7983
void numOutboundPeersChanged();
8084
void inHeaderSyncChanged();
8185
void headerSyncProgressChanged();
@@ -96,6 +100,7 @@ public Q_SLOTS:
96100
private:
97101
// Properties that are exposed to QML.
98102
int m_block_tip_height{0};
103+
bool m_in_ibd;
99104
int m_num_outbound_peers{0};
100105
static constexpr int m_max_num_outbound_peers{MAX_OUTBOUND_FULL_RELAY_CONNECTIONS + MAX_BLOCK_RELAY_ONLY_CONNECTIONS};
101106
bool m_in_header_sync;

0 commit comments

Comments
 (0)