]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
coins: don't refresh for each freeze/thaw
authortobtoht <tob@featherwallet.org>
Thu, 10 Oct 2024 12:22:47 +0000 (14:22 +0200)
committertobtoht <tob@featherwallet.org>
Thu, 10 Oct 2024 12:22:47 +0000 (14:22 +0200)
src/CoinsWidget.cpp
src/SendWidget.h
src/libwalletqt/Coins.cpp
src/libwalletqt/Coins.h

index 9c582da45f9a195ac221a1003d1ea8355a66ace5..8c15c7a7a1580f0e8992a65a0eaf79d72444724a 100644 (file)
@@ -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();
 }
 
index 1b310f2b4a14d553e1e8e4cf3027d44cc9a7c6b4..85efbf85e79eaf87a7a97464c3cc973072aa0719 100644 (file)
@@ -49,7 +49,7 @@ public slots:
     void disallowSending();
 
 private slots:
-    void onDataPasted(const QString &data);
+    void onDataFromQR(const QString &data);
 
 private:
     void setupComboBox();
index c5de0aaf79832d861d3f2312addd91376160f510..27b08b91aec3a57517357af915552746f1607876 100644 (file)
@@ -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)
index ce875c0dad2a52686f5c3dc46f428022d6324e01..7ea1e40aeb984f1dfe298f4ce5707bb2f37c7b4d 100644 (file)
@@ -31,8 +31,10 @@ public:
     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);
@@ -43,8 +45,6 @@ public:
 signals:
     void refreshStarted() const;
     void refreshFinished() const;
-    void coinFrozen() const;
-    void coinThawed() const;
     void descriptionChanged() const;
 
 private: