Skip to content

Commit

Permalink
qml: set synced to whether node is in IBD or not
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jarolrod committed Mar 1, 2023
1 parent cf5bfcb commit 6bfccd9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/qml/components/BlockClock.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Item {
property alias subText: subText.text
property int headerSize: 32
property bool connected: nodeModel.numOutboundPeers > 0
property bool synced: nodeModel.verificationProgress > 0.999
property bool synced: !nodeModel.inIBD
property bool paused: false

BlockClockDial {
Expand All @@ -30,7 +30,7 @@ Item {
timeRatioList: chainModel.timeRatioList
verificationProgress: nodeModel.verificationProgress
paused: root.paused
synced: nodeModel.verificationProgress > 0.999
synced: root.synced
backgroundColor: Theme.color.neutral2
timeTickColor: Theme.color.neutral5
confirmationColors: Theme.color.confirmationColors
Expand Down
11 changes: 11 additions & 0 deletions src/qml/nodemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ void NodeModel::setBlockTipHeight(int new_height)
}
}


void NodeModel::setInIBD(bool new_ibd)
{
if (new_ibd != m_in_ibd) {
m_in_ibd = new_ibd;
Q_EMIT inIBDChanged();
}
}

void NodeModel::setNumOutboundPeers(int new_num)
{
if (new_num != m_num_outbound_peers) {
Expand Down Expand Up @@ -183,6 +192,7 @@ void NodeModel::ConnectToBlockTipSignal()
[this](SynchronizationState state, interfaces::BlockTip tip, double verification_progress) {
QMetaObject::invokeMethod(this, [=] {
setBlockTipHeight(tip.block_height);
setInIBD(m_node.isInitialBlockDownload());
setVerificationProgress(verification_progress);
setInHeaderSync(false);
setInPreHeaderSync(false);
Expand All @@ -197,6 +207,7 @@ void NodeModel::ConnectToHeaderTipSignal()

m_handler_notify_header_tip = m_node.handleNotifyHeaderTip(
[this](SynchronizationState sync_state, interfaces::BlockTip tip, bool presync) {
setInIBD(m_node.isInitialBlockDownload());
QMetaObject::invokeMethod(this, [=] {
if (presync) {
setInHeaderSync(false);
Expand Down
5 changes: 5 additions & 0 deletions src/qml/nodemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class NodeModel : public QObject
{
Q_OBJECT
Q_PROPERTY(int blockTipHeight READ blockTipHeight NOTIFY blockTipHeightChanged)
Q_PROPERTY(bool inIBD READ inIBD NOTIFY inIBDChanged)
Q_PROPERTY(int numOutboundPeers READ numOutboundPeers NOTIFY numOutboundPeersChanged)
Q_PROPERTY(int maxNumOutboundPeers READ maxNumOutboundPeers CONSTANT)
Q_PROPERTY(bool inHeaderSync READ inHeaderSync WRITE setInHeaderSync NOTIFY inHeaderSyncChanged)
Expand All @@ -40,6 +41,8 @@ class NodeModel : public QObject

int blockTipHeight() const { return m_block_tip_height; }
void setBlockTipHeight(int new_height);
bool inIBD() const { return m_in_ibd; }
void setInIBD(bool new_ibd);
int numOutboundPeers() const { return m_num_outbound_peers; }
void setNumOutboundPeers(int new_num);
int maxNumOutboundPeers() const { return m_max_num_outbound_peers; }
Expand Down Expand Up @@ -68,6 +71,7 @@ public Q_SLOTS:

Q_SIGNALS:
void blockTipHeightChanged();
void inIBDChanged();
void numOutboundPeersChanged();
void inHeaderSyncChanged();
void headerSyncProgressChanged();
Expand All @@ -88,6 +92,7 @@ public Q_SLOTS:
private:
// Properties that are exposed to QML.
int m_block_tip_height{0};
bool m_in_ibd;
int m_num_outbound_peers{0};
static constexpr int m_max_num_outbound_peers{MAX_OUTBOUND_FULL_RELAY_CONNECTIONS + MAX_BLOCK_RELAY_ONLY_CONNECTIONS};
bool m_in_header_sync;
Expand Down

0 comments on commit 6bfccd9

Please sign in to comment.