Skip to content

Commit a198a04

Browse files
committed
Show number of InstantSend locks in Debug Console (dashpay#2919)
* Implement GetInstantSendLockCount in CInstantSendManager * Add islockCountChanged signal to client model * Show number of InstantSend locks in debug console
1 parent 013169d commit a198a04

File tree

7 files changed

+66
-0
lines changed

7 files changed

+66
-0
lines changed

src/llmq/quorums_instantsend.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,28 @@ bool CInstantSendDb::HasArchivedInstantSendLock(const uint256& islockHash)
185185
return db.Exists(std::make_tuple(std::string("is_a2"), islockHash));
186186
}
187187

188+
size_t CInstantSendDb::GetInstantSendLockCount()
189+
{
190+
auto it = std::unique_ptr<CDBIterator>(db.NewIterator());
191+
auto firstKey = std::make_tuple(std::string("is_i"), uint256());
192+
193+
it->Seek(firstKey);
194+
195+
size_t cnt = 0;
196+
while (it->Valid()) {
197+
decltype(firstKey) curKey;
198+
if (!it->GetKey(curKey) || std::get<0>(curKey) != "is_i") {
199+
break;
200+
}
201+
202+
cnt++;
203+
204+
it->Next();
205+
}
206+
207+
return cnt;
208+
}
209+
188210
CInstantSendLockPtr CInstantSendDb::GetInstantSendLockByHash(const uint256& hash)
189211
{
190212
CInstantSendLockPtr ret;
@@ -1412,6 +1434,11 @@ CInstantSendLockPtr CInstantSendManager::GetConflictingLock(const CTransaction&
14121434
return nullptr;
14131435
}
14141436

1437+
size_t CInstantSendManager::GetInstantSendLockCount()
1438+
{
1439+
return db.GetInstantSendLockCount();
1440+
}
1441+
14151442
void CInstantSendManager::WorkThreadMain()
14161443
{
14171444
while (!workInterrupt) {

src/llmq/quorums_instantsend.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class CInstantSendDb
6262
std::unordered_map<uint256, CInstantSendLockPtr> RemoveConfirmedInstantSendLocks(int nUntilHeight);
6363
void RemoveArchivedInstantSendLocks(int nUntilHeight);
6464
bool HasArchivedInstantSendLock(const uint256& islockHash);
65+
size_t GetInstantSendLockCount();
6566

6667
CInstantSendLockPtr GetInstantSendLockByHash(const uint256& hash);
6768
uint256 GetInstantSendLockHashByTxid(const uint256& txid);
@@ -159,6 +160,8 @@ class CInstantSendManager : public CRecoveredSigsListener
159160
bool AlreadyHave(const CInv& inv);
160161
bool GetInstantSendLockByHash(const uint256& hash, CInstantSendLock& ret);
161162

163+
size_t GetInstantSendLockCount();
164+
162165
void WorkThreadMain();
163166
};
164167

src/qt/clientmodel.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "masternode-sync.h"
2424
#include "privatesend.h"
2525

26+
#include "llmq/quorums_instantsend.h"
27+
2628
#include <stdint.h>
2729

2830
#include <QDebug>
@@ -161,6 +163,14 @@ size_t ClientModel::getMempoolDynamicUsage() const
161163
return mempool.DynamicMemoryUsage();
162164
}
163165

166+
size_t ClientModel::getInstantSentLockCount() const
167+
{
168+
if (!llmq::quorumInstantSendManager) {
169+
return 0;
170+
}
171+
return llmq::quorumInstantSendManager->GetInstantSendLockCount();
172+
}
173+
164174
double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const
165175
{
166176
CBlockIndex *tip = const_cast<CBlockIndex *>(tipIn);
@@ -177,6 +187,7 @@ void ClientModel::updateTimer()
177187
// no locking required at this point
178188
// the following calls will acquire the required lock
179189
Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage());
190+
Q_EMIT islockCountChanged(getInstantSentLockCount());
180191
Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent());
181192
}
182193

src/qt/clientmodel.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ class ClientModel : public QObject
6363
long getMempoolSize() const;
6464
//! Return the dynamic memory usage of the mempool
6565
size_t getMempoolDynamicUsage() const;
66+
//! Return number of ISLOCKs
67+
size_t getInstantSentLockCount() const;
6668

6769
void setMasternodeList(const CDeterministicMNList& mnList);
6870
CDeterministicMNList getMasternodeList() const;
@@ -117,6 +119,7 @@ class ClientModel : public QObject
117119
void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header);
118120
void additionalDataSyncProgressChanged(double nSyncProgress);
119121
void mempoolSizeChanged(long count, size_t mempoolSizeInBytes);
122+
void islockCountChanged(size_t count);
120123
void networkActiveChanged(bool networkActive);
121124
void alertsChanged(const QString &warnings);
122125
void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut);

src/qt/forms/debugwindow.ui

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,20 @@
408408
</property>
409409
</spacer>
410410
</item>
411+
<item row="16" column="0">
412+
<widget class="QLabel" name="labelInstantSendLockCount">
413+
<property name="text">
414+
<string>InstantSend locks</string>
415+
</property>
416+
</widget>
417+
</item>
418+
<item row="16" column="1">
419+
<widget class="QLabel" name="instantSendLockCount">
420+
<property name="text">
421+
<string>N/A</string>
422+
</property>
423+
</widget>
424+
</item>
411425
</layout>
412426
</widget>
413427
<widget class="QWidget" name="tab_console">

src/qt/rpcconsole.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ void RPCConsole::setClientModel(ClientModel *model)
563563
connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64)));
564564

565565
connect(model, SIGNAL(mempoolSizeChanged(long,size_t)), this, SLOT(setMempoolSize(long,size_t)));
566+
connect(model, SIGNAL(islockCountChanged(size_t)), this, SLOT(setInstantSendLockCount(size_t)));
566567

567568
// set up peer table
568569
ui->peerWidget->setModel(model->getPeerTableModel());
@@ -906,6 +907,11 @@ void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage)
906907
ui->mempoolSize->setText(QString::number(dynUsage/1000000.0, 'f', 2) + " MB");
907908
}
908909

910+
void RPCConsole::setInstantSendLockCount(size_t count)
911+
{
912+
ui->instantSendLockCount->setText(QString::number(count));
913+
}
914+
909915
void RPCConsole::on_lineEdit_returnPressed()
910916
{
911917
QString cmd = ui->lineEdit->text();

src/qt/rpcconsole.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public Q_SLOTS:
111111
void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
112112
/** Set size (number of transactions and memory usage) of the mempool in the UI */
113113
void setMempoolSize(long numberOfTxs, size_t dynUsage);
114+
/** Set number of InstantSend locks */
115+
void setInstantSendLockCount(size_t count);
114116
/** Go forward or back in history */
115117
void browseHistory(int offset);
116118
/** Scroll console view to end */

0 commit comments

Comments
 (0)