Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/llmq/quorums_instantsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CDBIterator>(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;
Expand Down Expand Up @@ -1410,6 +1432,11 @@ CInstantSendLockPtr CInstantSendManager::GetConflictingLock(const CTransaction&
return nullptr;
}

size_t CInstantSendManager::GetInstantSendLockCount()
{
return db.GetInstantSendLockCount();
}

void CInstantSendManager::WorkThreadMain()
{
while (!workInterrupt) {
Expand Down
3 changes: 3 additions & 0 deletions src/llmq/quorums_instantsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class CInstantSendDb
std::unordered_map<uint256, CInstantSendLockPtr> 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);
Expand Down Expand Up @@ -159,6 +160,8 @@ class CInstantSendManager : public CRecoveredSigsListener
bool AlreadyHave(const CInv& inv);
bool GetInstantSendLockByHash(const uint256& hash, CInstantSendLock& ret);

size_t GetInstantSendLockCount();

void WorkThreadMain();
};

Expand Down
11 changes: 11 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "masternode-sync.h"
#include "privatesend.h"

#include "llmq/quorums_instantsend.h"

#include <stdint.h>

#include <QDebug>
Expand Down Expand Up @@ -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<CBlockIndex *>(tipIn);
Expand All @@ -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());
}

Expand Down
3 changes: 3 additions & 0 deletions src/qt/clientmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class ClientModel : public QObject
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;
Expand Down Expand Up @@ -117,6 +119,7 @@ class ClientModel : public QObject
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);
Expand Down
14 changes: 14 additions & 0 deletions src/qt/forms/debugwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,20 @@
</property>
</spacer>
</item>
<item row="16" column="0">
<widget class="QLabel" name="labelInstantSendLockCount">
<property name="text">
<string>InstantSend locks</string>
</property>
</widget>
</item>
<item row="16" column="1">
<widget class="QLabel" name="instantSendLockCount">
<property name="text">
<string>N/A</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_console">
Expand Down
6 changes: 6 additions & 0 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/qt/rpcconsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down