Skip to content

Commit

Permalink
coins: don't refresh for each freeze/thaw
Browse files Browse the repository at this point in the history
  • Loading branch information
tobtoht committed Oct 10, 2024
1 parent 796d4dd commit fdc7a09
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 43 deletions.
10 changes: 2 additions & 8 deletions src/CoinsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,12 @@ QVector<CoinsInfo*> CoinsWidget::currentEntries() {
}

void CoinsWidget::freezeCoins(QStringList &pubkeys) {
for (auto &pubkey : pubkeys) {
m_wallet->coins()->freeze(pubkey);
}
m_wallet->coins()->refresh();
m_wallet->coins()->freeze(pubkeys);
m_wallet->updateBalance();
}

void CoinsWidget::thawCoins(QStringList &pubkeys) {
for (auto &pubkey : pubkeys) {
m_wallet->coins()->thaw(pubkey);
}
m_wallet->coins()->refresh();
m_wallet->coins()->thaw(pubkeys);
m_wallet->updateBalance();
}

Expand Down
2 changes: 1 addition & 1 deletion src/SendWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public slots:
void disallowSending();

private slots:
void onDataPasted(const QString &data);
void onDataFromQR(const QString &data);

private:
void setupComboBox();
Expand Down
64 changes: 34 additions & 30 deletions src/libwalletqt/Coins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,48 +105,52 @@ quint64 Coins::count() const
return m_rows.length();
}

void Coins::freeze(QString &publicKey)
void Coins::freeze(QStringList &publicKeys)
{
crypto::public_key pk;
if (!epee::string_tools::hex_to_pod(publicKey.toStdString(), pk))
{
qWarning() << "Invalid public key: " << publicKey;
return;
}

try
{
m_wallet2->freeze(pk);
refresh();
}
catch (const std::exception& e)
{
qWarning() << "freeze: " << e.what();
for (const auto& publicKey : publicKeys) {
if (!epee::string_tools::hex_to_pod(publicKey.toStdString(), pk))
{
qWarning() << "Invalid public key: " << publicKey;
continue;
}

try
{
m_wallet2->freeze(pk);
}
catch (const std::exception& e)
{
qWarning() << "freeze: " << e.what();
}
}

emit coinFrozen();
refresh();
}

void Coins::thaw(QString &publicKey)
void Coins::thaw(QStringList &publicKeys)
{
crypto::public_key pk;
if (!epee::string_tools::hex_to_pod(publicKey.toStdString(), pk))
{
qWarning() << "Invalid public key: " << publicKey;
return;
}

try
{
m_wallet2->thaw(pk);
refresh();
}
catch (const std::exception& e)
{
qWarning() << "thaw: " << e.what();
for (const auto& publicKey : publicKeys) {
if (!epee::string_tools::hex_to_pod(publicKey.toStdString(), pk))
{
qWarning() << "Invalid public key: " << publicKey;
continue;
}

try
{
m_wallet2->thaw(pk);
}
catch (const std::exception& e)
{
qWarning() << "thaw: " << e.what();
}
}

emit coinThawed();
refresh();
}

QVector<CoinsInfo*> Coins::coins_from_txid(const QString &txid)
Expand Down
8 changes: 4 additions & 4 deletions src/libwalletqt/Coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ Q_OBJECT
CoinsInfo * coin(int index);
void refresh();
void refreshUnlocked();
void freeze(QString &publicKey);
void thaw(QString &publicKey);

void freeze(QStringList &publicKeys);
void thaw(QStringList &publicKeys);

QVector<CoinsInfo*> coins_from_txid(const QString &txid);
QVector<CoinsInfo*> coinsFromKeyImage(const QStringList &keyimages);
void setDescription(const QString &publicKey, quint32 accountIndex, const QString &description);
Expand All @@ -43,8 +45,6 @@ Q_OBJECT
signals:
void refreshStarted() const;
void refreshFinished() const;
void coinFrozen() const;
void coinThawed() const;
void descriptionChanged() const;

private:
Expand Down

0 comments on commit fdc7a09

Please sign in to comment.