|
|
@ -48,14 +48,16 @@ RPC::RPC(MainWindow* main) { |
|
|
|
qDebug() << "setting up timer for rescan data"; |
|
|
|
|
|
|
|
rescanTimer = new QTimer(main); |
|
|
|
// PreciseTimer is needed for timely GUI updates
|
|
|
|
rescanTimer->setTimerType(Qt::PreciseTimer); |
|
|
|
|
|
|
|
QObject::connect(rescanTimer, &QTimer::timeout, [=]() { |
|
|
|
qDebug() << "Refreshing rescan data"; |
|
|
|
refreshRescan(); |
|
|
|
}); |
|
|
|
|
|
|
|
rescanTimer->start(1000); |
|
|
|
qDebug() << __func__ << ": started rescanTimer"; |
|
|
|
rescanTimer->start(Settings::updateSpeed); |
|
|
|
|
|
|
|
|
|
|
|
qDebug() << __func__ << ": Setting up a timer to refresh the UI every few seconds"; |
|
|
|
timer = new QTimer(main); |
|
|
@ -64,6 +66,8 @@ RPC::RPC(MainWindow* main) { |
|
|
|
refresh(); |
|
|
|
}); |
|
|
|
timer->start(Settings::updateSpeed); |
|
|
|
// PreciseTimer is needed for timely GUI updates
|
|
|
|
timer->setTimerType(Qt::PreciseTimer); |
|
|
|
|
|
|
|
qDebug() << __func__ << ": Set up the timer to watch for tx status"; |
|
|
|
txTimer = new QTimer(main); |
|
|
@ -198,7 +202,8 @@ void RPC::rescan(qint64 height, const std::function<void(QJsonValue)>& cb) { |
|
|
|
// get rescan info
|
|
|
|
void RPC::getRescanInfo(const std::function<void(QJsonValue)>& cb){ |
|
|
|
QString method = "getrescaninfo"; |
|
|
|
conn->doRPCWithDefaultErrorHandling(makePayload(method), cb); |
|
|
|
// do not show an error in case getrescaninfo doesn't exist in this hushd
|
|
|
|
conn->doRPCIgnoreError(makePayload(method), cb); |
|
|
|
} |
|
|
|
|
|
|
|
// get help
|
|
|
@ -1002,36 +1007,27 @@ void RPC::refreshBalances() { |
|
|
|
void RPC::refreshRescan() { |
|
|
|
qDebug() << __func__; |
|
|
|
if (conn == nullptr) { |
|
|
|
qDebug() << __func__ << ": no connection"; |
|
|
|
return noConnection(); |
|
|
|
} |
|
|
|
|
|
|
|
conn->doRPC(makePayload("help", "getrescaninfo"), [=] (const QJsonValue& reply) { |
|
|
|
qDebug() << __func__ << ": found getrescaninfo: reply=" << reply; |
|
|
|
// Get rescan info
|
|
|
|
QObject::connect(rescanTimer, &QTimer::timeout, [=]() { |
|
|
|
qDebug() << "setting callback for getrescaninfo"; |
|
|
|
getRescanInfo([=] (QJsonValue response){ |
|
|
|
qDebug() << "got getrescaninfo json"; |
|
|
|
auto rescanning = response.toObject().value("rescanning").toBool(); |
|
|
|
auto rescan_progress = response.toObject().value("rescan_progress").toString(); |
|
|
|
auto rescan_start_height = (qint64)response.toObject().value("rescan_start_height").toInt(); |
|
|
|
auto rescan_height = (qint64)response.toObject().value("rescan_height").toInt(); |
|
|
|
double percent = QString(rescan_progress).toDouble() * 100; |
|
|
|
qDebug() << __func__ << ": getrescaninfo" << rescanning << " " << percent << " " << rescan_start_height << " " << rescan_height; |
|
|
|
|
|
|
|
if(rescanning){ |
|
|
|
pauseTimer(); |
|
|
|
qDebug() << __func__ << ": Rescanning at " << percent << " %"; |
|
|
|
ui->statusBar->showMessage(QObject::tr("Rescanning... ") + QString::number(percent)+ "% " + QObject::tr("at height") + " " + QString::number(rescan_height)); |
|
|
|
} else{ |
|
|
|
qDebug() << __func__ << ": not rescanning"; |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, [=](QNetworkReply* reply, const QJsonValue&) { |
|
|
|
qDebug() << __func__ << ": missing getrescaninfo, no rescan progress will be shown: reply=" << reply; |
|
|
|
getRescanInfo([=] (QJsonValue response){ |
|
|
|
qDebug() << "got getrescaninfo json=" << response; |
|
|
|
auto rescanning = response.toObject().value("rescanning").toBool(); |
|
|
|
auto rescan_progress = response.toObject().value("rescan_progress").toString(); |
|
|
|
auto rescan_start_height = (qint64)response.toObject().value("rescan_start_height").toInt(); |
|
|
|
auto rescan_height = (qint64)response.toObject().value("rescan_height").toInt(); |
|
|
|
double percent = QString(rescan_progress).toDouble() * 100; |
|
|
|
qDebug() << __func__ << ": getrescaninfo" << rescanning << " " << percent << " " << rescan_start_height << " " << rescan_height; |
|
|
|
|
|
|
|
if(rescanning){ |
|
|
|
// pauseTimer();
|
|
|
|
qDebug() << __func__ << ": Rescanning at " << percent << "e"; |
|
|
|
ui->statusBar->showMessage(QObject::tr("Rescanning... ") + QString::number(percent)+ "% " + QObject::tr("at height") + " " + QString::number(rescan_height)); |
|
|
|
} else{ |
|
|
|
qDebug() << __func__ << ": not rescanning"; |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
void RPC::refreshPeers() { |
|
|
|