Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing UI stuck issues on huge wallets #1172

Merged
merged 3 commits into from
Jun 5, 2022
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
7 changes: 5 additions & 2 deletions src/qt/automintmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

IncomingFundNotifier::IncomingFundNotifier(
CWallet *_wallet, QObject *parent) :
QObject(parent), wallet(_wallet), timer(0)
QObject(parent), wallet(_wallet), timer(0), lastUpdateTime(0)
{
timer = new QTimer(this);
timer->setSingleShot(true);
Expand Down Expand Up @@ -58,10 +58,13 @@ void IncomingFundNotifier::check()
{
LOCK(cs);

if (txs.empty()) {
// update only if there are transaction and last update was done more than 2 minutes ago, and in case it is first time
if (txs.empty() || (lastUpdateTime!= 0 && (GetSystemTimeInSeconds() - lastUpdateTime <= 120))) {
return;
}

lastUpdateTime = GetSystemTimeInSeconds();

CAmount credit = 0;
std::vector<uint256> immatures;

Expand Down
2 changes: 2 additions & 0 deletions src/qt/automintmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public Q_SLOTS:

std::vector<uint256> txs;
mutable CCriticalSection cs;

int64_t lastUpdateTime;
};

class AutoMintModel : public QObject
Expand Down
5 changes: 3 additions & 2 deletions src/qt/transactiontablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,9 @@ void TransactionTableModel::updateConfirmations()
// Invalidate status (number of confirmations) and (possibly) description
// for all rows. Qt is smart enough to only actually request the data for the
// visible rows.
Q_EMIT dataChanged(index(0, Status), index(priv->size()-1, Status));
Q_EMIT dataChanged(index(0, ToAddress), index(priv->size()-1, ToAddress));
int numRows = std::min(1000, priv->size()-1);
Q_EMIT dataChanged(index(0, Status), index(numRows, Status));
Q_EMIT dataChanged(index(0, ToAddress), index(numRows, ToAddress));
}

void TransactionTableModel::updateNumISLocks(int numISLocks)
Expand Down
43 changes: 0 additions & 43 deletions src/qt/walletmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,41 +157,6 @@ void WalletModel::pollBalanceChanged()
checkBalanceChanged();
if(transactionTableModel)
transactionTableModel->updateConfirmations();

// check sigma
// support only hd
if (wallet->zwallet) {
checkSigmaAmount(false);
}
}
}

void WalletModel::updateSigmaCoins(const QString &pubCoin, const QString &isUsed, int status)
{
if (status == ChangeType::CT_UPDATED) {
// some coin have been updated to be used
LOCK2(cs_main, wallet->cs_wallet);
checkSigmaAmount(true);

} else if (status == ChangeType::CT_NEW) {
// new mint
LOCK2(cs_main, wallet->cs_wallet);
auto coins = wallet->zwallet->GetTracker().ListMints(true, false, false);

int block = cachedNumBlocks;
for (const auto& coin : coins) {
if (!coin.isUsed) {
int coinHeight = coin.nHeight;
if (coinHeight == -1
|| (coinHeight <= block && coinHeight > block - ZC_MINT_CONFIRMATIONS)) {
cachedHavePendingCoin = true;
}
}
}

if (cachedHavePendingCoin) {
checkSigmaAmount(true);
}
}
}

Expand Down Expand Up @@ -966,14 +931,6 @@ static void NotifyZerocoinChanged(WalletModel *walletmodel, CWallet *wallet, con
Q_ARG(QString, QString::fromStdString(pubCoin)),
Q_ARG(QString, QString::fromStdString(isUsed)),
Q_ARG(int, status));

// disable sigma
if (wallet->zwallet) {
QMetaObject::invokeMethod(walletmodel, "updateSigmaCoins", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(pubCoin)),
Q_ARG(QString, QString::fromStdString(isUsed)),
Q_ARG(int, status));
}
}

static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
Expand Down
2 changes: 0 additions & 2 deletions src/qt/walletmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ public Q_SLOTS:
void updateWatchOnlyFlag(bool fHaveWatchonly);
/* Current, immature or unconfirmed balance might have changed - emit 'balanceChanged' if so */
void pollBalanceChanged();
/* Update Amount of sigma change */
void updateSigmaCoins(const QString &pubCoin, const QString &isUsed, int status);
// Handle the changed BIP47 privkeys
void handleBip47Keys(int receiverAccountNum, void * pBlockIndex);
// Locks wallet from timer calls
Expand Down