Skip to content

Commit ff100bb

Browse files
committed
Merge #825: Show maximum mempool size in information window
4a028cf gui: show maximum mempool size in information window (Sebastian Falbesoner) bbde6ff add node interface method for getting maximum mempool size (Sebastian Falbesoner) Pull request description: This PR adds the maximum mempool size to the information window (Menu "Window" -> "Information" -> section "Memory Pool" -> line "Memory usage"). master: ![image](https://github.com/bitcoin-core/gui/assets/91535/157e92f5-7d06-4303-b4ef-bcdfac5527e3) PR: ![image](https://github.com/bitcoin-core/gui/assets/91535/796322aa-9f16-4b09-9893-bf52a3898a5c) ACKs for top commit: MarnixCroes: tested ACK 4a028cf pablomartin4btc: tACK 4a028cf luke-jr: tACK 4a028cf & in Knots hebasto: ACK 4a028cf, tested on Ubuntu 24.04. Tree-SHA512: c10fb23605d060cea19a86d11822fc4d12496b19547870052aace503670e62e4c4e19ae4c2c4fbf7420a472adb071c9ddebe82447e0cfbce5a6fb9fcd7b9eda3
2 parents c4d45b6 + 4a028cf commit ff100bb

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

src/interfaces/node.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ class Node
162162
//! Get mempool dynamic usage.
163163
virtual size_t getMempoolDynamicUsage() = 0;
164164

165+
//! Get mempool maximum memory usage.
166+
virtual size_t getMempoolMaxUsage() = 0;
167+
165168
//! Get header tip height and time.
166169
virtual bool getHeaderTip(int& height, int64_t& block_time) = 0;
167170

src/node/interfaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class NodeImpl : public Node
278278
int64_t getTotalBytesSent() override { return m_context->connman ? m_context->connman->GetTotalBytesSent() : 0; }
279279
size_t getMempoolSize() override { return m_context->mempool ? m_context->mempool->size() : 0; }
280280
size_t getMempoolDynamicUsage() override { return m_context->mempool ? m_context->mempool->DynamicMemoryUsage() : 0; }
281+
size_t getMempoolMaxUsage() override { return m_context->mempool ? m_context->mempool->m_opts.max_size_bytes : 0; }
281282
bool getHeaderTip(int& height, int64_t& block_time) override
282283
{
283284
LOCK(::cs_main);

src/qt/clientmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QO
5353
connect(timer, &QTimer::timeout, [this] {
5454
// no locking required at this point
5555
// the following calls will acquire the required lock
56-
Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage());
56+
Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage(), m_node.getMempoolMaxUsage());
5757
Q_EMIT bytesChanged(m_node.getTotalBytesRecv(), m_node.getTotalBytesSent());
5858
});
5959
connect(m_thread, &QThread::finished, timer, &QObject::deleteLater);

src/qt/clientmodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class ClientModel : public QObject
113113
Q_SIGNALS:
114114
void numConnectionsChanged(int count);
115115
void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType header, SynchronizationState sync_state);
116-
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
116+
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes, size_t mempoolMaxSizeInBytes);
117117
void networkActiveChanged(bool networkActive);
118118
void alertsChanged(const QString &warnings);
119119
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);

src/qt/rpcconsole.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,15 +1000,16 @@ void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate, double nVer
10001000
}
10011001
}
10021002

1003-
void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage)
1003+
void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage, size_t maxUsage)
10041004
{
10051005
ui->mempoolNumberTxs->setText(QString::number(numberOfTxs));
10061006

1007-
if (dynUsage < 1000000) {
1008-
ui->mempoolSize->setText(QObject::tr("%1 kB").arg(dynUsage / 1000.0, 0, 'f', 2));
1009-
} else {
1010-
ui->mempoolSize->setText(QObject::tr("%1 MB").arg(dynUsage / 1000000.0, 0, 'f', 2));
1011-
}
1007+
const auto cur_usage_str = dynUsage < 1000000 ?
1008+
QObject::tr("%1 kB").arg(dynUsage / 1000.0, 0, 'f', 2) :
1009+
QObject::tr("%1 MB").arg(dynUsage / 1000000.0, 0, 'f', 2);
1010+
const auto max_usage_str = QObject::tr("%1 MB").arg(maxUsage / 1000000.0, 0, 'f', 2);
1011+
1012+
ui->mempoolSize->setText(cur_usage_str + " / " + max_usage_str);
10121013
}
10131014

10141015
void RPCConsole::on_lineEdit_returnPressed()
@@ -1400,4 +1401,4 @@ void RPCConsole::updateWindowTitle()
14001401
const QString chainType = QString::fromStdString(Params().GetChainTypeString());
14011402
const QString title = tr("Node window - [%1]").arg(chainType);
14021403
this->setWindowTitle(title);
1403-
}
1404+
}

src/qt/rpcconsole.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public Q_SLOTS:
121121
/** Set number of blocks and last block date shown in the UI */
122122
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype);
123123
/** Set size (number of transactions and memory usage) of the mempool in the UI */
124-
void setMempoolSize(long numberOfTxs, size_t dynUsage);
124+
void setMempoolSize(long numberOfTxs, size_t dynUsage, size_t maxUsage);
125125
/** Go forward or back in history */
126126
void browseHistory(int offset);
127127
/** Scroll console view to end */

0 commit comments

Comments
 (0)