aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2024-07-14 12:55:05 +0100
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2024-07-14 13:07:44 +0100
commitff100bb549f21dc0136af9241fd2de6daffb19a2 (patch)
tree34e57fe9718f3ca1e6474d4c1bf07b22a67b74d0
parentc4d45b695ef27e21d35e886b08887e2ecf272ce7 (diff)
parent4a028cf54c0502bc9ba0804bf1ae413b20a007cb (diff)
downloadbitcoin-ff100bb549f21dc0136af9241fd2de6daffb19a2.tar.xz
Merge bitcoin-core/gui#825: Show maximum mempool size in information window
4a028cf54c0502bc9ba0804bf1ae413b20a007cb gui: show maximum mempool size in information window (Sebastian Falbesoner) bbde6ffefea9587b07a9f8d4043b2dd23ef8c3c5 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 4a028cf54c0502bc9ba0804bf1ae413b20a007cb pablomartin4btc: tACK 4a028cf54c0502bc9ba0804bf1ae413b20a007cb luke-jr: tACK 4a028cf54c0502bc9ba0804bf1ae413b20a007cb & in Knots hebasto: ACK 4a028cf54c0502bc9ba0804bf1ae413b20a007cb, tested on Ubuntu 24.04. Tree-SHA512: c10fb23605d060cea19a86d11822fc4d12496b19547870052aace503670e62e4c4e19ae4c2c4fbf7420a472adb071c9ddebe82447e0cfbce5a6fb9fcd7b9eda3
-rw-r--r--src/interfaces/node.h3
-rw-r--r--src/node/interfaces.cpp1
-rw-r--r--src/qt/clientmodel.cpp2
-rw-r--r--src/qt/clientmodel.h2
-rw-r--r--src/qt/rpcconsole.cpp15
-rw-r--r--src/qt/rpcconsole.h2
6 files changed, 15 insertions, 10 deletions
diff --git a/src/interfaces/node.h b/src/interfaces/node.h
index a56e79148d..b9b2306ce3 100644
--- a/src/interfaces/node.h
+++ b/src/interfaces/node.h
@@ -162,6 +162,9 @@ public:
//! Get mempool dynamic usage.
virtual size_t getMempoolDynamicUsage() = 0;
+ //! Get mempool maximum memory usage.
+ virtual size_t getMempoolMaxUsage() = 0;
+
//! Get header tip height and time.
virtual bool getHeaderTip(int& height, int64_t& block_time) = 0;
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index fa151407fa..ef12ffe34b 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -278,6 +278,7 @@ public:
int64_t getTotalBytesSent() override { return m_context->connman ? m_context->connman->GetTotalBytesSent() : 0; }
size_t getMempoolSize() override { return m_context->mempool ? m_context->mempool->size() : 0; }
size_t getMempoolDynamicUsage() override { return m_context->mempool ? m_context->mempool->DynamicMemoryUsage() : 0; }
+ size_t getMempoolMaxUsage() override { return m_context->mempool ? m_context->mempool->m_opts.max_size_bytes : 0; }
bool getHeaderTip(int& height, int64_t& block_time) override
{
LOCK(::cs_main);
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 2f3bad37e6..0b03e3071c 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -53,7 +53,7 @@ ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QO
connect(timer, &QTimer::timeout, [this] {
// no locking required at this point
// the following calls will acquire the required lock
- Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage());
+ Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage(), m_node.getMempoolMaxUsage());
Q_EMIT bytesChanged(m_node.getTotalBytesRecv(), m_node.getTotalBytesSent());
});
connect(m_thread, &QThread::finished, timer, &QObject::deleteLater);
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index 624056b5df..7727359f99 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -113,7 +113,7 @@ private:
Q_SIGNALS:
void numConnectionsChanged(int count);
void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType header, SynchronizationState sync_state);
- void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
+ void mempoolSizeChanged(long count, size_t mempoolSizeInBytes, size_t mempoolMaxSizeInBytes);
void networkActiveChanged(bool networkActive);
void alertsChanged(const QString &warnings);
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index edf417a7cb..fb731e4e90 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -1000,15 +1000,16 @@ void RPCConsole::setNumBlocks(int count, const QDateTime& blockDate, double nVer
}
}
-void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage)
+void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage, size_t maxUsage)
{
ui->mempoolNumberTxs->setText(QString::number(numberOfTxs));
- if (dynUsage < 1000000) {
- ui->mempoolSize->setText(QObject::tr("%1 kB").arg(dynUsage / 1000.0, 0, 'f', 2));
- } else {
- ui->mempoolSize->setText(QObject::tr("%1 MB").arg(dynUsage / 1000000.0, 0, 'f', 2));
- }
+ const auto cur_usage_str = dynUsage < 1000000 ?
+ QObject::tr("%1 kB").arg(dynUsage / 1000.0, 0, 'f', 2) :
+ QObject::tr("%1 MB").arg(dynUsage / 1000000.0, 0, 'f', 2);
+ const auto max_usage_str = QObject::tr("%1 MB").arg(maxUsage / 1000000.0, 0, 'f', 2);
+
+ ui->mempoolSize->setText(cur_usage_str + " / " + max_usage_str);
}
void RPCConsole::on_lineEdit_returnPressed()
@@ -1400,4 +1401,4 @@ void RPCConsole::updateWindowTitle()
const QString chainType = QString::fromStdString(Params().GetChainTypeString());
const QString title = tr("Node window - [%1]").arg(chainType);
this->setWindowTitle(title);
-} \ No newline at end of file
+}
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index d6a5035c33..4747e611d0 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -121,7 +121,7 @@ public Q_SLOTS:
/** Set number of blocks and last block date shown in the UI */
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, SyncType synctype);
/** Set size (number of transactions and memory usage) of the mempool in the UI */
- void setMempoolSize(long numberOfTxs, size_t dynUsage);
+ void setMempoolSize(long numberOfTxs, size_t dynUsage, size_t maxUsage);
/** Go forward or back in history */
void browseHistory(int offset);
/** Scroll console view to end */