diff --git a/src/connection.h b/src/connection.h index b72886b..cafd196 100644 --- a/src/connection.h +++ b/src/connection.h @@ -106,9 +106,22 @@ public: std::function*)> cb) { auto responses = new QMap(); // zAddr -> list of responses for each call. int totalSize = payloads.size(); + if (totalSize == 0) + return; + + // Keep track of all pending method calls, so as to prevent + // any overlapping calls + static QMap inProgress; + + QString method = QString::fromStdString(payloadGenerator(payloads[0])["method"]); + if (inProgress.value(method, false)) { + qDebug() << "In progress batch, skipping"; + return; + } for (auto item: payloads) { json payload = payloadGenerator(item); + inProgress[method] = true; QNetworkReply *reply = restclient->post(*request, QByteArray::fromStdString(payload.dump())); @@ -148,7 +161,10 @@ public: // If all responses have arrived, return if (responses->size() == totalSize) { waitTimer->stop(); + cb(responses); + inProgress[method] = false; + waitTimer->deleteLater(); } }); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 34eb791..fbfcb01 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -16,7 +16,6 @@ #include "senttxstore.h" #include "connection.h" -#include "precompiled.h" using json = nlohmann::json; diff --git a/src/rpc.h b/src/rpc.h index c198532..42fa646 100644 --- a/src/rpc.h +++ b/src/rpc.h @@ -88,9 +88,6 @@ private: void getTransactions (const std::function& cb); void getZAddresses (const std::function& cb); - void handleConnectionError (const QString& error); - void handleTxError (const QString& error); - Connection* conn = nullptr; QProcess* ezcashd = nullptr;