Skip to content

Commit b979bdc

Browse files
committed
Merge #383: Put BlockClock into an error state if node init fails
2b61d22 qml: Put BlockClock into an Error state if init fails (johnny9) Pull request description: Initial step for adding error states to the NodeRunner Link to github actions build artifacts. [![Build Artifacts](https://img.shields.io/badge/Build%20Artifacts-green )]() ACKs for top commit: pablomartin4btc: tACK 2b61d22 MarnixCroes: tACK 2b61d22 Tree-SHA512: 5da6e8cde6e7d24dbd1adffa8014622e188e5ec1abc17b260ba696239c5cc7558a57c6650336549ccfb715cc17fb2b72f28dc107d86e3a21f46f307357525ac7
2 parents 48bc2c8 + 2b61d22 commit b979bdc

File tree

8 files changed

+55
-8
lines changed

8 files changed

+55
-8
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ QML_RES_ICONS = \
335335
qml/res/icons/caret-right.png \
336336
qml/res/icons/check.png \
337337
qml/res/icons/cross.png \
338+
qml/res/icons/error.png \
338339
qml/res/icons/export.png \
339340
qml/res/icons/gear.png \
340341
qml/res/icons/gear-outline.png \

src/qml/bitcoin_qml.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
<file alias="caret-right">res/icons/caret-right.png</file>
9191
<file alias="check">res/icons/check.png</file>
9292
<file alias="cross">res/icons/cross.png</file>
93+
<file alias="error">res/icons/error.png</file>
9394
<file alias="export">res/icons/export.png</file>
9495
<file alias="gear">res/icons/gear.png</file>
9596
<file alias="gear-outline">res/icons/gear-outline.png</file>

src/qml/components/BlockClock.qml

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Item {
3232
property var syncState: Utils.formatRemainingSyncTime(nodeModel.remainingSyncTime)
3333
property string syncTime: syncState.text
3434
property bool estimating: syncState.estimating
35+
property bool faulted: nodeModel.faulted
3536

3637
activeFocusOnTab: true
3738

@@ -50,7 +51,7 @@ Item {
5051
penWidth: dial.width / 50
5152
timeRatioList: chainModel.timeRatioList
5253
verificationProgress: nodeModel.verificationProgress
53-
paused: root.paused
54+
paused: root.paused || root.faulted
5455
connected: root.connected
5556
synced: nodeModel.verificationProgress > 0.999
5657
backgroundColor: Theme.color.neutral2
@@ -143,7 +144,7 @@ Item {
143144
maxNumOutboundPeers: nodeModel.maxNumOutboundPeers
144145
indicatorDimensions: dial.width * (3/200)
145146
indicatorSpacing: dial.width / 40
146-
paused: root.paused
147+
paused: root.paused || root.faulted
147148
}
148149

149150
NetworkIndicator {
@@ -156,10 +157,13 @@ Item {
156157

157158
MouseArea {
158159
anchors.fill: dial
159-
cursorShape: Qt.PointingHandCursor
160+
cursorShape: root.faulted ? Qt.ArrowCursor : Qt.PointingHandCursor
161+
enabled: !root.faulted
160162
onClicked: {
161-
root.paused = !root.paused
162-
nodeModel.pause = root.paused
163+
if (!root.faulted) {
164+
root.paused = !root.paused
165+
nodeModel.pause = root.paused
166+
}
163167
}
164168
FocusBorder {
165169
visible: root.activeFocus
@@ -175,6 +179,7 @@ Item {
175179
subText: root.syncTime
176180
}
177181
},
182+
178183
State {
179184
name: "BLOCKCLOCK"; when: synced && !paused && connected
180185
PropertyChanges {
@@ -186,7 +191,7 @@ Item {
186191
},
187192

188193
State {
189-
name: "PAUSE"; when: paused
194+
name: "PAUSE"; when: paused && !faulted
190195
PropertyChanges {
191196
target: root
192197
header: "Paused"
@@ -204,6 +209,20 @@ Item {
204209
}
205210
},
206211

212+
State {
213+
name: "ERROR"; when: faulted
214+
PropertyChanges {
215+
target: root
216+
header: "Error"
217+
headerSize: dial.width * (3/25)
218+
}
219+
PropertyChanges {
220+
target: bitcoinIcon
221+
anchors.bottomMargin: dial.width / 40
222+
icon.source: "image://images/error"
223+
}
224+
},
225+
207226
State {
208227
name: "CONNECTING"; when: !paused && !connected
209228
PropertyChanges {
@@ -224,6 +243,7 @@ Item {
224243
}
225244
]
226245

246+
227247
function formatProgressPercentage(progress) {
228248
if (progress >= 1) {
229249
return Math.round(progress) + "%"

src/qml/imageprovider.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ QPixmap ImageProvider::requestPixmap(const QString& id, QSize* size, const QSize
8282
return QIcon(":/icons/cross").pixmap(requested_size);
8383
}
8484

85+
if (id == "error") {
86+
*size = requested_size;
87+
return QIcon(":/icons/error").pixmap(requested_size);
88+
}
89+
8590
if (id == "export") {
8691
*size = requested_size;
8792
return QIcon(":/icons/export").pixmap(requested_size);

src/qml/models/nodemodel.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QDateTime>
1616
#include <QMetaObject>
1717
#include <QTimerEvent>
18+
#include <QString>
1819

1920
NodeModel::NodeModel(interfaces::Node& node)
2021
: m_node{node}
@@ -93,6 +94,14 @@ void NodeModel::setPause(bool new_pause)
9394
}
9495
}
9596

97+
void NodeModel::setErrorState(bool faulted)
98+
{
99+
if (m_faulted != faulted) {
100+
m_faulted = faulted;
101+
Q_EMIT errorStateChanged(faulted);
102+
}
103+
}
104+
96105
void NodeModel::startNodeInitializionThread()
97106
{
98107
Q_EMIT requestedInitialize();
@@ -103,9 +112,11 @@ void NodeModel::requestShutdown()
103112
Q_EMIT requestedShutdown();
104113
}
105114

106-
void NodeModel::initializeResult([[maybe_unused]] bool success, interfaces::BlockAndHeaderTipInfo tip_info)
115+
void NodeModel::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info)
107116
{
108-
// TODO: Handle the `success` parameter,
117+
if (!success) {
118+
setErrorState(true);
119+
}
109120
setBlockTipHeight(tip_info.block_height);
110121
setVerificationProgress(tip_info.verification_progress);
111122

src/qml/models/nodemodel.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class NodeModel : public QObject
3333
Q_PROPERTY(int remainingSyncTime READ remainingSyncTime NOTIFY remainingSyncTimeChanged)
3434
Q_PROPERTY(double verificationProgress READ verificationProgress NOTIFY verificationProgressChanged)
3535
Q_PROPERTY(bool pause READ pause WRITE setPause NOTIFY pauseChanged)
36+
Q_PROPERTY(bool faulted READ errorState WRITE setErrorState NOTIFY errorStateChanged)
3637

3738
public:
3839
explicit NodeModel(interfaces::Node& node);
@@ -49,6 +50,8 @@ class NodeModel : public QObject
4950
void setVerificationProgress(double new_progress);
5051
bool pause() const { return m_pause; }
5152
void setPause(bool new_pause);
53+
bool errorState() const { return m_faulted; }
54+
void setErrorState(bool new_error);
5255

5356
Q_INVOKABLE float getTotalBytesReceived() const { return (float)m_node.getTotalBytesRecv(); }
5457
Q_INVOKABLE float getTotalBytesSent() const { return (float)m_node.getTotalBytesSent(); }
@@ -70,6 +73,7 @@ public Q_SLOTS:
7073
void requestedShutdown();
7174
void verificationProgressChanged();
7275
void pauseChanged(bool new_pause);
76+
void errorStateChanged(bool new_error_state);
7377

7478
void setTimeRatioList(int new_time);
7579
void setTimeRatioListInitial();
@@ -85,6 +89,7 @@ public Q_SLOTS:
8589
int m_remaining_sync_time{0};
8690
double m_verification_progress{0.0};
8791
bool m_pause{false};
92+
bool m_faulted{false};
8893

8994
int m_shutdown_polling_timer_id{0};
9095

src/qml/res/icons/error.png

3.41 KB
Loading

src/qml/res/src/error.svg

Lines changed: 4 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)