Browse Source

Log opid, creation time and execution time of z ops

pull/102/head
Jonathan "Duke" Leto 5 years ago
parent
commit
dfc729784a
  1. 17
      src/rpc.cpp
  2. 6
      src/sendtab.cpp

17
src/rpc.cpp

@ -961,31 +961,30 @@ void RPC::watchTxStatus() {
return noConnection(); return noConnection();
// Make an RPC to load pending operation statues // Make an RPC to load pending operation statues
json payload = { conn->doRPCIgnoreError(makePayload("z_getoperationstatus"), [=] (const json& reply) {
{"jsonrpc", "1.0"}, // conn->doRPCIgnoreError(payload, [=] (const json& reply) {
{"id", "someid"},
{"method", "z_getoperationstatus"},
};
conn->doRPCIgnoreError(payload, [=] (const json& reply) {
// There's an array for each item in the status // There's an array for each item in the status
for (auto& it : reply.get<json::array_t>()) { for (auto& it : reply.get<json::array_t>()) {
// If we were watching this Tx and its status became "success", then we'll show a status bar alert // If we were watching this Tx and its status became "success", then we'll show a status bar alert
QString id = QString::fromStdString(it["id"]); QString id = QString::fromStdString(it["id"]);
if (watchingOps.contains(id)) { if (watchingOps.contains(id)) {
// log any txs we are watching
// "creation_time": 1515969376,
// "execution_secs": 50.416337,
// And if it ended up successful // And if it ended up successful
QString status = QString::fromStdString(it["status"]); QString status = QString::fromStdString(it["status"]);
main->loadingLabel->setVisible(false); main->loadingLabel->setVisible(false);
if (status == "success") { if (status == "success") {
auto txid = QString::fromStdString(it["result"]["txid"]); auto txid = QString::fromStdString(it["result"]["txid"]);
SentTxStore::addToSentTx(watchingOps[id].tx, txid); SentTxStore::addToSentTx(watchingOps[id].tx, txid);
auto wtx = watchingOps[id]; auto wtx = watchingOps[id];
watchingOps.remove(id); watchingOps.remove(id);
wtx.completed(id, txid); wtx.completed(id, txid);
qDebug() << "opid "<< id << " started at "<<QString::number((unsigned int)it["creation_time"])<<" took " << QString::number((double)it["execution_secs"]) << " seconds";
// Refresh balances to show unconfirmed balances // Refresh balances to show unconfirmed balances
refresh(true); refresh(true);
} else if (status == "failed") { } else if (status == "failed") {
@ -1010,7 +1009,7 @@ void RPC::watchTxStatus() {
main->loadingLabel->setVisible(false); main->loadingLabel->setVisible(false);
} else { } else {
main->loadingLabel->setVisible(true); main->loadingLabel->setVisible(true);
main->loadingLabel->setToolTip(QString::number(watchingOps.size()) + QObject::tr(" tx computing. This can take several minutes.")); main->loadingLabel->setToolTip(QString::number(watchingOps.size()) + QObject::tr(" transaction computing."));
} }
}); });
} }

6
src/sendtab.cpp

@ -1,3 +1,4 @@
// Copyright 2019 The Hush developers
#include "mainwindow.h" #include "mainwindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
#include "addressbook.h" #include "addressbook.h"
@ -711,13 +712,14 @@ void MainWindow::sendButton() {
// And send the Tx // And send the Tx
rpc->executeTransaction(tx, rpc->executeTransaction(tx,
[=] (QString opid) { [=] (QString opid) {
ui->statusBar->showMessage(tr("Computing Tx: ") % opid); ui->statusBar->showMessage(tr("Computing transaction: ") % opid);
qDebug() << "Computing opid: " << opid;
}, },
[=] (QString, QString txid) { [=] (QString, QString txid) {
ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid);
}, },
[=] (QString opid, QString errStr) { [=] (QString opid, QString errStr) {
ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000); ui->statusBar->showMessage(QObject::tr(" Transaction ") % opid % QObject::tr(" failed"), 15 * 1000);
if (!opid.isEmpty()) if (!opid.isEmpty())
errStr = QObject::tr("The transaction with id ") % opid % QObject::tr(" failed. The error was") + ":\n\n" + errStr; errStr = QObject::tr("The transaction with id ") % opid % QObject::tr(" failed. The error was") + ":\n\n" + errStr;

Loading…
Cancel
Save