Skip to content

Commit 4e1b06b

Browse files
committed
merge bitcoin-core/gui#825: Show maximum mempool size in information window
1 parent 568753a commit 4e1b06b

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

src/interfaces/node.h

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

236+
//! Get mempool maximum memory usage.
237+
virtual size_t getMempoolMaxUsage() = 0;
238+
236239
//! Get header tip height and time.
237240
virtual bool getHeaderTip(int& height, int64_t& block_time) = 0;
238241

src/node/interfaces.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ class NodeImpl : public Node
519519
int64_t getTotalBytesSent() override { return m_context->connman ? m_context->connman->GetTotalBytesSent() : 0; }
520520
size_t getMempoolSize() override { return m_context->mempool ? m_context->mempool->size() : 0; }
521521
size_t getMempoolDynamicUsage() override { return m_context->mempool ? m_context->mempool->DynamicMemoryUsage() : 0; }
522+
size_t getMempoolMaxUsage() override { return gArgs.GetIntArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000; }
522523
bool getHeaderTip(int& height, int64_t& block_time) override
523524
{
524525
LOCK(::cs_main);

src/qt/clientmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QO
5757
connect(timer, &QTimer::timeout, [this] {
5858
// no locking required at this point
5959
// the following calls will acquire the required lock
60-
Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage());
60+
Q_EMIT mempoolSizeChanged(m_node.getMempoolSize(), m_node.getMempoolDynamicUsage(), m_node.getMempoolMaxUsage());
6161
Q_EMIT islockCountChanged(m_node.llmq().getInstantSentLockCount());
6262
});
6363
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
@@ -130,7 +130,7 @@ class ClientModel : public QObject
130130
void chainLockChanged(const QString& bestChainLockHash, int bestChainLockHeight);
131131
void numBlocksChanged(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool header, SynchronizationState sync_state);
132132
void additionalDataSyncProgressChanged(double nSyncProgress);
133-
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
133+
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes, size_t mempoolMaxSizeInBytes);
134134
void islockCountChanged(size_t count);
135135
void networkActiveChanged(bool networkActive);
136136
void alertsChanged(const QString &warnings);

src/qt/rpcconsole.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,14 +1095,16 @@ void RPCConsole::updateMasternodeCount()
10951095
ui->evoCount->setText(strEvoCount);
10961096
}
10971097

1098-
void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage)
1098+
void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage, size_t maxUsage)
10991099
{
11001100
ui->mempoolNumberTxs->setText(QString::number(numberOfTxs));
11011101

1102-
if (dynUsage < 1000000)
1103-
ui->mempoolSize->setText(QString::number(dynUsage/1000.0, 'f', 2) + " KB");
1104-
else
1105-
ui->mempoolSize->setText(QString::number(dynUsage/1000000.0, 'f', 2) + " MB");
1102+
const auto cur_usage_str = dynUsage < 1000000 ?
1103+
QObject::tr("%1 kB").arg(dynUsage / 1000.0, 0, 'f', 2) :
1104+
QObject::tr("%1 MB").arg(dynUsage / 1000000.0, 0, 'f', 2);
1105+
const auto max_usage_str = QObject::tr("%1 MB").arg(maxUsage / 1000000.0, 0, 'f', 2);
1106+
1107+
ui->mempoolSize->setText(cur_usage_str + " / " + max_usage_str);
11061108
}
11071109

11081110
void RPCConsole::setInstantSendLockCount(size_t count)

src/qt/rpcconsole.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public Q_SLOTS:
128128
/** Set number of blocks, last block date and last block hash shown in the UI */
129129
void setNumBlocks(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool headers);
130130
/** Set size (number of transactions and memory usage) of the mempool in the UI */
131-
void setMempoolSize(long numberOfTxs, size_t dynUsage);
131+
void setMempoolSize(long numberOfTxs, size_t dynUsage, size_t maxUsage);
132132
/** Set number of InstantSend locks */
133133
void setInstantSendLockCount(size_t count);
134134
/** Go forward or back in history */

0 commit comments

Comments
 (0)