From 9853dc17a0a7cbd3dc0b133061916935d20c14d0 Mon Sep 17 00:00:00 2001 From: adityapk00 Date: Sat, 10 Nov 2018 12:38:17 -0800 Subject: [PATCH] Ignore errors for background ops --- src/rpc.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index b32fd7c..bf7293b 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -486,7 +486,9 @@ void RPC::getInfoThenRefresh(bool force) { {"method", "getinfo"} }; + static bool prevCallSucceeded = false; conn->doRPC(payload, [=] (const json& reply) { + prevCallSucceeded = true; // Testnet? if (!reply["testnet"].is_null()) { Settings::getInstance()->setTestnet(reply["testnet"].get()); @@ -575,8 +577,12 @@ void RPC::getInfoThenRefresh(bool force) { }, [=](QNetworkReply* reply, const json& replyJson) { // zcashd has probably disappeared. this->noConnection(); - QMessageBox::critical(main, "Connection Error", "There was an error connecting to zcashd. The error was: \n\n" - + reply->errorString(), QMessageBox::StandardButton::Ok); + if (prevCallSucceeded) { // show error only first time + QMessageBox::critical(main, "Connection Error", "There was an error connecting to zcashd. The error was: \n\n" + + reply->errorString(), QMessageBox::StandardButton::Ok); + } + + prevCallSucceeded = false; }); } @@ -774,7 +780,7 @@ void RPC::watchTxStatus() { {"method", "z_getoperationstatus"}, }; - conn->doRPCWithDefaultErrorHandling(payload, [=] (const json& reply) { + conn->doRPCIgnoreError(payload, [=] (const json& reply) { // There's an array for each item in the status for (auto& it : reply.get()) { // If we were watching this Tx and its status became "success", then we'll show a status bar alert