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. 25
      src/rpc.cpp
  2. 14
      src/sendtab.cpp

25
src/rpc.cpp

@ -108,7 +108,7 @@ json RPC::makePayload(std::string method, std::string params) {
{"method", method },
{"params", {params}}
};
return payload;
return payload;
}
json RPC::makePayload(std::string method) {
@ -117,7 +117,7 @@ json RPC::makePayload(std::string method) {
{"id", "42" },
{"method", method },
};
return payload;
return payload;
}
void RPC::getTAddresses(const std::function<void(json)>& cb) {
@ -961,35 +961,34 @@ void RPC::watchTxStatus() {
return noConnection();
// Make an RPC to load pending operation statues
json payload = {
{"jsonrpc", "1.0"},
{"id", "someid"},
{"method", "z_getoperationstatus"},
};
conn->doRPCIgnoreError(payload, [=] (const json& reply) {
conn->doRPCIgnoreError(makePayload("z_getoperationstatus"), [=] (const json& reply) {
// conn->doRPCIgnoreError(payload, [=] (const json& reply) {
// There's an array for each item in the status
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
QString id = QString::fromStdString(it["id"]);
if (watchingOps.contains(id)) {
// log any txs we are watching
// "creation_time": 1515969376,
// "execution_secs": 50.416337,
// And if it ended up successful
QString status = QString::fromStdString(it["status"]);
main->loadingLabel->setVisible(false);
if (status == "success") {
auto txid = QString::fromStdString(it["result"]["txid"]);
SentTxStore::addToSentTx(watchingOps[id].tx, txid);
auto wtx = watchingOps[id];
watchingOps.remove(id);
wtx.completed(id, txid);
// Refresh balances to show unconfirmed balances
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(true);
} else if (status == "failed") {
// If it failed, then we'll actually show a warning.
// If it failed, then we'll actually show a warning.
auto errorMsg = QString::fromStdString(it["error"]["message"]);
auto wtx = watchingOps[id];
@ -1010,7 +1009,7 @@ void RPC::watchTxStatus() {
main->loadingLabel->setVisible(false);
} else {
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."));
}
});
}

14
src/sendtab.cpp

@ -1,3 +1,4 @@
// Copyright 2019 The Hush developers
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "addressbook.h"
@ -705,27 +706,28 @@ void MainWindow::sendButton() {
// abort the Tx
return;
}
// Show a dialog to confirm the Tx
if (confirmTx(tx)) {
// And send the Tx
rpc->executeTransaction(tx,
rpc->executeTransaction(tx,
[=] (QString opid) {
ui->statusBar->showMessage(tr("Computing Tx: ") % opid);
ui->statusBar->showMessage(tr("Computing transaction: ") % opid);
qDebug() << "Computing opid: " << opid;
},
[=] (QString, QString txid) {
ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid);
},
[=] (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())
errStr = QObject::tr("The transaction with id ") % opid % QObject::tr(" failed. The error was") + ":\n\n" + errStr;
QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok);
QMessageBox::critical(this, QObject::tr("Transaction Error"), errStr, QMessageBox::Ok);
}
);
}
}
}
QString MainWindow::doSendTxValidations(Tx tx) {

Loading…
Cancel
Save