Skip to content

Commit 776848a

Browse files
committed
Merge pull request #6979
c197798 [Qt] simple mempool info in debug window (Jonas Schnelli)
2 parents 07b770c + c197798 commit 776848a

File tree

5 files changed

+136
-44
lines changed

5 files changed

+136
-44
lines changed

src/qt/clientmodel.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "checkpoints.h"
1414
#include "clientversion.h"
1515
#include "net.h"
16+
#include "txmempool.h"
1617
#include "ui_interface.h"
1718
#include "util.h"
1819

@@ -88,6 +89,16 @@ QDateTime ClientModel::getLastBlockDate() const
8889
return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network
8990
}
9091

92+
long ClientModel::getMempoolSize() const
93+
{
94+
return mempool.size();
95+
}
96+
97+
size_t ClientModel::getMempoolDynamicUsage() const
98+
{
99+
return mempool.DynamicMemoryUsage();
100+
}
101+
91102
double ClientModel::getVerificationProgress() const
92103
{
93104
LOCK(cs_main);
@@ -122,6 +133,7 @@ void ClientModel::updateTimer()
122133
Q_EMIT numBlocksChanged(newNumBlocks, newBlockDate);
123134
}
124135

136+
Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage());
125137
Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent());
126138
}
127139

src/qt/clientmodel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class ClientModel : public QObject
5151
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
5252
int getNumBlocks() const;
5353

54+
//! Return number of transactions in the mempool
55+
long getMempoolSize() const;
56+
//! Return the dynamic memory usage of the mempool
57+
size_t getMempoolDynamicUsage() const;
58+
5459
quint64 getTotalBytesRecv() const;
5560
quint64 getTotalBytesSent() const;
5661

@@ -89,6 +94,7 @@ class ClientModel : public QObject
8994
Q_SIGNALS:
9095
void numConnectionsChanged(int count);
9196
void numBlocksChanged(int count, const QDateTime& blockDate);
97+
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
9298
void alertsChanged(const QString &warnings);
9399
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
94100

src/qt/forms/debugwindow.ui

Lines changed: 104 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<attribute name="title">
2424
<string>&amp;Information</string>
2525
</attribute>
26-
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
26+
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0">
2727
<property name="horizontalSpacing">
2828
<number>12</number>
2929
</property>
@@ -47,7 +47,7 @@
4747
</property>
4848
</widget>
4949
</item>
50-
<item row="1" column="1">
50+
<item row="1" column="1" colspan="2">
5151
<widget class="QLabel" name="clientName">
5252
<property name="cursor">
5353
<cursorShape>IBeamCursor</cursorShape>
@@ -70,7 +70,7 @@
7070
</property>
7171
</widget>
7272
</item>
73-
<item row="2" column="1">
73+
<item row="2" column="1" colspan="2">
7474
<widget class="QLabel" name="clientVersion">
7575
<property name="cursor">
7676
<cursorShape>IBeamCursor</cursorShape>
@@ -96,7 +96,7 @@
9696
</property>
9797
</widget>
9898
</item>
99-
<item row="3" column="1">
99+
<item row="3" column="1" colspan="2">
100100
<widget class="QLabel" name="clientUserAgent">
101101
<property name="cursor">
102102
<cursorShape>IBeamCursor</cursorShape>
@@ -122,7 +122,7 @@
122122
</property>
123123
</widget>
124124
</item>
125-
<item row="4" column="1">
125+
<item row="4" column="1" colspan="2">
126126
<widget class="QLabel" name="openSSLVersion">
127127
<property name="cursor">
128128
<cursorShape>IBeamCursor</cursorShape>
@@ -148,7 +148,7 @@
148148
</property>
149149
</widget>
150150
</item>
151-
<item row="5" column="1">
151+
<item row="5" column="1" colspan="2">
152152
<widget class="QLabel" name="berkeleyDBVersion">
153153
<property name="cursor">
154154
<cursorShape>IBeamCursor</cursorShape>
@@ -171,7 +171,7 @@
171171
</property>
172172
</widget>
173173
</item>
174-
<item row="6" column="1">
174+
<item row="6" column="1" colspan="2">
175175
<widget class="QLabel" name="buildDate">
176176
<property name="cursor">
177177
<cursorShape>IBeamCursor</cursorShape>
@@ -194,7 +194,7 @@
194194
</property>
195195
</widget>
196196
</item>
197-
<item row="7" column="1">
197+
<item row="7" column="1" colspan="2">
198198
<widget class="QLabel" name="startupTime">
199199
<property name="cursor">
200200
<cursorShape>IBeamCursor</cursorShape>
@@ -210,27 +210,14 @@
210210
</property>
211211
</widget>
212212
</item>
213-
<item row="8" column="0">
214-
<widget class="QLabel" name="label_11">
215-
<property name="font">
216-
<font>
217-
<weight>75</weight>
218-
<bold>true</bold>
219-
</font>
220-
</property>
221-
<property name="text">
222-
<string>Network</string>
223-
</property>
224-
</widget>
225-
</item>
226213
<item row="9" column="0">
227214
<widget class="QLabel" name="label_8">
228215
<property name="text">
229216
<string>Name</string>
230217
</property>
231218
</widget>
232219
</item>
233-
<item row="9" column="1">
220+
<item row="9" column="1" colspan="2">
234221
<widget class="QLabel" name="networkName">
235222
<property name="cursor">
236223
<cursorShape>IBeamCursor</cursorShape>
@@ -253,7 +240,7 @@
253240
</property>
254241
</widget>
255242
</item>
256-
<item row="10" column="1">
243+
<item row="10" column="1" colspan="2">
257244
<widget class="QLabel" name="numberOfConnections">
258245
<property name="cursor">
259246
<cursorShape>IBeamCursor</cursorShape>
@@ -289,7 +276,7 @@
289276
</property>
290277
</widget>
291278
</item>
292-
<item row="12" column="1">
279+
<item row="12" column="1" colspan="2">
293280
<widget class="QLabel" name="numberOfBlocks">
294281
<property name="cursor">
295282
<cursorShape>IBeamCursor</cursorShape>
@@ -306,13 +293,13 @@
306293
</widget>
307294
</item>
308295
<item row="13" column="0">
309-
<widget class="QLabel" name="label_2">
296+
<widget class="QLabel" name="labelLastBlockTime">
310297
<property name="text">
311298
<string>Last block time</string>
312299
</property>
313300
</widget>
314301
</item>
315-
<item row="13" column="1">
302+
<item row="13" column="1" colspan="2">
316303
<widget class="QLabel" name="lastBlockTime">
317304
<property name="cursor">
318305
<cursorShape>IBeamCursor</cursorShape>
@@ -329,45 +316,118 @@
329316
</widget>
330317
</item>
331318
<item row="14" column="0">
332-
<spacer name="verticalSpacer_2">
333-
<property name="orientation">
334-
<enum>Qt::Vertical</enum>
319+
<widget class="QLabel" name="labelMempoolTitle">
320+
<property name="font">
321+
<font>
322+
<weight>75</weight>
323+
<bold>true</bold>
324+
</font>
335325
</property>
336-
<property name="sizeHint" stdset="0">
337-
<size>
338-
<width>20</width>
339-
<height>20</height>
340-
</size>
326+
<property name="text">
327+
<string>Memory Pool</string>
341328
</property>
342-
</spacer>
329+
</widget>
343330
</item>
344331
<item row="15" column="0">
345-
<widget class="QLabel" name="labelDebugLogfile">
332+
<widget class="QLabel" name="labelNumberOfTransactions">
333+
<property name="text">
334+
<string>Current number of transactions</string>
335+
</property>
336+
</widget>
337+
</item>
338+
<item row="15" column="1">
339+
<widget class="QLabel" name="mempoolNumberTxs">
340+
<property name="cursor">
341+
<cursorShape>IBeamCursor</cursorShape>
342+
</property>
343+
<property name="text">
344+
<string>N/A</string>
345+
</property>
346+
<property name="textFormat">
347+
<enum>Qt::PlainText</enum>
348+
</property>
349+
<property name="textInteractionFlags">
350+
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
351+
</property>
352+
</widget>
353+
</item>
354+
<item row="8" column="0">
355+
<widget class="QLabel" name="labelNetwork">
346356
<property name="font">
347357
<font>
348358
<weight>75</weight>
349359
<bold>true</bold>
350360
</font>
351361
</property>
352362
<property name="text">
353-
<string>Debug log file</string>
363+
<string>Network</string>
354364
</property>
355365
</widget>
356366
</item>
357367
<item row="16" column="0">
358-
<widget class="QPushButton" name="openDebugLogfileButton">
359-
<property name="toolTip">
360-
<string>Open the Bitcoin Core debug log file from the current data directory. This can take a few seconds for large log files.</string>
368+
<widget class="QLabel" name="labelMemoryUsage">
369+
<property name="text">
370+
<string>Memory usage</string>
371+
</property>
372+
</widget>
373+
</item>
374+
<item row="16" column="1">
375+
<widget class="QLabel" name="mempoolSize">
376+
<property name="cursor">
377+
<cursorShape>IBeamCursor</cursorShape>
361378
</property>
362379
<property name="text">
363-
<string>&amp;Open</string>
380+
<string>N/A</string>
364381
</property>
365-
<property name="autoDefault">
366-
<bool>false</bool>
382+
<property name="textFormat">
383+
<enum>Qt::PlainText</enum>
384+
</property>
385+
<property name="textInteractionFlags">
386+
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
367387
</property>
368388
</widget>
369389
</item>
370-
<item row="17" column="0">
390+
<item row="14" column="2" rowspan="3">
391+
<layout class="QVBoxLayout" name="verticalLayoutDebugButton">
392+
<property name="spacing">
393+
<number>3</number>
394+
</property>
395+
<item>
396+
<spacer name="verticalSpacer_2">
397+
<property name="orientation">
398+
<enum>Qt::Vertical</enum>
399+
</property>
400+
<property name="sizeHint" stdset="0">
401+
<size>
402+
<width>10</width>
403+
<height>5</height>
404+
</size>
405+
</property>
406+
</spacer>
407+
</item>
408+
<item>
409+
<widget class="QLabel" name="labelDebugLogfile">
410+
<property name="text">
411+
<string>Debug log file</string>
412+
</property>
413+
</widget>
414+
</item>
415+
<item>
416+
<widget class="QPushButton" name="openDebugLogfileButton">
417+
<property name="toolTip">
418+
<string>Open the Bitcoin Core debug log file from the current data directory. This can take a few seconds for large log files.</string>
419+
</property>
420+
<property name="text">
421+
<string>&amp;Open</string>
422+
</property>
423+
<property name="autoDefault">
424+
<bool>false</bool>
425+
</property>
426+
</widget>
427+
</item>
428+
</layout>
429+
</item>
430+
<item row="18" column="0">
371431
<spacer name="verticalSpacer">
372432
<property name="orientation">
373433
<enum>Qt::Vertical</enum>

src/qt/rpcconsole.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ void RPCConsole::setClientModel(ClientModel *model)
343343
updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent());
344344
connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64)));
345345

346+
connect(model, SIGNAL(mempoolSizeChanged(long,size_t)), this, SLOT(setMempoolSize(long,size_t)));
347+
346348
// set up peer table
347349
ui->peerWidget->setModel(model->getPeerTableModel());
348350
ui->peerWidget->verticalHeader()->hide();
@@ -523,6 +525,16 @@ void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate)
523525
ui->lastBlockTime->setText(blockDate.toString());
524526
}
525527

528+
void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage)
529+
{
530+
ui->mempoolNumberTxs->setText(QString::number(numberOfTxs));
531+
532+
if (dynUsage < 1000000)
533+
ui->mempoolSize->setText(QString::number(dynUsage/1000.0, 'f', 2) + " KB");
534+
else
535+
ui->mempoolSize->setText(QString::number(dynUsage/1000000.0, 'f', 2) + " MB");
536+
}
537+
526538
void RPCConsole::on_lineEdit_returnPressed()
527539
{
528540
QString cmd = ui->lineEdit->text();

src/qt/rpcconsole.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ public Q_SLOTS:
8484
void setNumConnections(int count);
8585
/** Set number of blocks and last block date shown in the UI */
8686
void setNumBlocks(int count, const QDateTime& blockDate);
87+
/** Set size (number of transactions and memory usage) of the mempool in the UI */
88+
void setMempoolSize(long numberOfTxs, size_t dynUsage);
8789
/** Go forward or back in history */
8890
void browseHistory(int offset);
8991
/** Scroll console view to end */

0 commit comments

Comments
 (0)