diff --git a/src/llmq/quorums_instantsend.cpp b/src/llmq/quorums_instantsend.cpp index dd92643090..807d9c7ed6 100644 --- a/src/llmq/quorums_instantsend.cpp +++ b/src/llmq/quorums_instantsend.cpp @@ -185,6 +185,28 @@ bool CInstantSendDb::HasArchivedInstantSendLock(const uint256& islockHash) return db.Exists(std::make_tuple(std::string("is_a2"), islockHash)); } +size_t CInstantSendDb::GetInstantSendLockCount() +{ + auto it = std::unique_ptr(db.NewIterator()); + auto firstKey = std::make_tuple(std::string("is_i"), uint256()); + + it->Seek(firstKey); + + size_t cnt = 0; + while (it->Valid()) { + decltype(firstKey) curKey; + if (!it->GetKey(curKey) || std::get<0>(curKey) != "is_i") { + break; + } + + cnt++; + + it->Next(); + } + + return cnt; +} + CInstantSendLockPtr CInstantSendDb::GetInstantSendLockByHash(const uint256& hash) { CInstantSendLockPtr ret; @@ -1410,6 +1432,11 @@ CInstantSendLockPtr CInstantSendManager::GetConflictingLock(const CTransaction& return nullptr; } +size_t CInstantSendManager::GetInstantSendLockCount() +{ + return db.GetInstantSendLockCount(); +} + void CInstantSendManager::WorkThreadMain() { while (!workInterrupt) { diff --git a/src/llmq/quorums_instantsend.h b/src/llmq/quorums_instantsend.h index 955b132235..456ba44bb7 100644 --- a/src/llmq/quorums_instantsend.h +++ b/src/llmq/quorums_instantsend.h @@ -62,6 +62,7 @@ public: std::unordered_map RemoveConfirmedInstantSendLocks(int nUntilHeight); void RemoveArchivedInstantSendLocks(int nUntilHeight); bool HasArchivedInstantSendLock(const uint256& islockHash); + size_t GetInstantSendLockCount(); CInstantSendLockPtr GetInstantSendLockByHash(const uint256& hash); uint256 GetInstantSendLockHashByTxid(const uint256& txid); @@ -159,6 +160,8 @@ public: bool AlreadyHave(const CInv& inv); bool GetInstantSendLockByHash(const uint256& hash, CInstantSendLock& ret); + size_t GetInstantSendLockCount(); + void WorkThreadMain(); }; diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index b8db901739..0a636c476d 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -23,6 +23,8 @@ #include "masternode/masternode-sync.h" #include "privatesend/privatesend.h" +#include "llmq/quorums_instantsend.h" + #include #include @@ -161,6 +163,14 @@ size_t ClientModel::getMempoolDynamicUsage() const return mempool.DynamicMemoryUsage(); } +size_t ClientModel::getInstantSentLockCount() const +{ + if (!llmq::quorumInstantSendManager) { + return 0; + } + return llmq::quorumInstantSendManager->GetInstantSendLockCount(); +} + double ClientModel::getVerificationProgress(const CBlockIndex *tipIn) const { CBlockIndex *tip = const_cast(tipIn); @@ -177,6 +187,7 @@ void ClientModel::updateTimer() // no locking required at this point // the following calls will acquire the required lock Q_EMIT mempoolSizeChanged(getMempoolSize(), getMempoolDynamicUsage()); + Q_EMIT islockCountChanged(getInstantSentLockCount()); Q_EMIT bytesChanged(getTotalBytesRecv(), getTotalBytesSent()); } diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index d3b429f0b4..846a71d46a 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -63,6 +63,8 @@ public: long getMempoolSize() const; //! Return the dynamic memory usage of the mempool size_t getMempoolDynamicUsage() const; + //! Return number of ISLOCKs + size_t getInstantSentLockCount() const; void setMasternodeList(const CDeterministicMNList& mnList); CDeterministicMNList getMasternodeList() const; @@ -117,6 +119,7 @@ Q_SIGNALS: void numBlocksChanged(int count, const QDateTime& blockDate, double nVerificationProgress, bool header); void additionalDataSyncProgressChanged(double nSyncProgress); void mempoolSizeChanged(long count, size_t mempoolSizeInBytes); + void islockCountChanged(size_t count); void networkActiveChanged(bool networkActive); void alertsChanged(const QString &warnings); void bytesChanged(quint64 totalBytesIn, quint64 totalBytesOut); diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index 0710120a39..5853f48b6f 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -408,6 +408,20 @@ + + + + InstantSend locks + + + + + + + N/A + + + diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 01f5c4aeec..cb1a80c129 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -563,6 +563,7 @@ void RPCConsole::setClientModel(ClientModel *model) connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64))); connect(model, SIGNAL(mempoolSizeChanged(long,size_t)), this, SLOT(setMempoolSize(long,size_t))); + connect(model, SIGNAL(islockCountChanged(size_t)), this, SLOT(setInstantSendLockCount(size_t))); // set up peer table ui->peerWidget->setModel(model->getPeerTableModel()); @@ -906,6 +907,11 @@ void RPCConsole::setMempoolSize(long numberOfTxs, size_t dynUsage) ui->mempoolSize->setText(QString::number(dynUsage/1000000.0, 'f', 2) + " MB"); } +void RPCConsole::setInstantSendLockCount(size_t count) +{ + ui->instantSendLockCount->setText(QString::number(count)); +} + void RPCConsole::on_lineEdit_returnPressed() { QString cmd = ui->lineEdit->text(); diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 8f195cde5a..c1466cf44f 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -111,6 +111,8 @@ public Q_SLOTS: void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers); /** Set size (number of transactions and memory usage) of the mempool in the UI */ void setMempoolSize(long numberOfTxs, size_t dynUsage); + /** Set number of InstantSend locks */ + void setInstantSendLockCount(size_t count); /** Go forward or back in history */ void browseHistory(int offset); /** Scroll console view to end */