Skip to content

Commit 6bfccd9

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 cf5bfcb commit 6bfccd9

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
@@ -21,7 +21,7 @@ Item {
2121
property alias subText: subText.text
2222
property int headerSize: 32
2323
property bool connected: nodeModel.numOutboundPeers > 0
24-
property bool synced: nodeModel.verificationProgress > 0.999
24+
property bool synced: !nodeModel.inIBD
2525
property bool paused: false
2626

2727
BlockClockDial {
@@ -30,7 +30,7 @@ Item {
3030
timeRatioList: chainModel.timeRatioList
3131
verificationProgress: nodeModel.verificationProgress
3232
paused: root.paused
33-
synced: nodeModel.verificationProgress > 0.999
33+
synced: root.synced
3434
backgroundColor: Theme.color.neutral2
3535
timeTickColor: Theme.color.neutral5
3636
confirmationColors: Theme.color.confirmationColors

src/qml/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) {
@@ -183,6 +192,7 @@ void NodeModel::ConnectToBlockTipSignal()
183192
[this](SynchronizationState state, interfaces::BlockTip tip, double verification_progress) {
184193
QMetaObject::invokeMethod(this, [=] {
185194
setBlockTipHeight(tip.block_height);
195+
setInIBD(m_node.isInitialBlockDownload());
186196
setVerificationProgress(verification_progress);
187197
setInHeaderSync(false);
188198
setInPreHeaderSync(false);
@@ -197,6 +207,7 @@ void NodeModel::ConnectToHeaderTipSignal()
197207

198208
m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(
199209
[this](SynchronizationState sync_state, interfaces::BlockTip tip, bool presync) {
210+
setInIBD(m_node.isInitialBlockDownload());
200211
QMetaObject::invokeMethod(this, [=] {
201212
if (presync) {
202213
setInHeaderSync(false);

src/qml/nodemodel.h

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class NodeModel : public QObject
2525
{
2626
Q_OBJECT
2727
Q_PROPERTY(int blockTipHeight READ blockTipHeight NOTIFY blockTipHeightChanged)
28+
Q_PROPERTY(bool inIBD READ inIBD NOTIFY inIBDChanged)
2829
Q_PROPERTY(int numOutboundPeers READ numOutboundPeers NOTIFY numOutboundPeersChanged)
2930
Q_PROPERTY(int maxNumOutboundPeers READ maxNumOutboundPeers CONSTANT)
3031
Q_PROPERTY(bool inHeaderSync READ inHeaderSync WRITE setInHeaderSync NOTIFY inHeaderSyncChanged)
@@ -40,6 +41,8 @@ class NodeModel : public QObject
4041

4142
int blockTipHeight() const { return m_block_tip_height; }
4243
void setBlockTipHeight(int new_height);
44+
bool inIBD() const { return m_in_ibd; }
45+
void setInIBD(bool new_ibd);
4346
int numOutboundPeers() const { return m_num_outbound_peers; }
4447
void setNumOutboundPeers(int new_num);
4548
int maxNumOutboundPeers() const { return m_max_num_outbound_peers; }
@@ -68,6 +71,7 @@ public Q_SLOTS:
6871

6972
Q_SIGNALS:
7073
void blockTipHeightChanged();
74+
void inIBDChanged();
7175
void numOutboundPeersChanged();
7276
void inHeaderSyncChanged();
7377
void headerSyncProgressChanged();
@@ -88,6 +92,7 @@ public Q_SLOTS:
8892
private:
8993
// Properties that are exposed to QML.
9094
int m_block_tip_height{0};
95+
bool m_in_ibd;
9196
int m_num_outbound_peers{0};
9297
static constexpr int m_max_num_outbound_peers{MAX_OUTBOUND_FULL_RELAY_CONNECTIONS + MAX_BLOCK_RELAY_ONLY_CONNECTIONS};
9398
bool m_in_header_sync;

0 commit comments

Comments
 (0)