Try another server if current is down when saving wallet via a rescan
This commit is contained in:
@@ -364,12 +364,11 @@ void Executor::run()
|
|||||||
nullptr,
|
nullptr,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
if (parsed.is_discarded() || parsed.is_null())
|
if (parsed.is_discarded() || parsed.is_null()) {
|
||||||
emit handleError(reply);
|
emit handleError(reply);
|
||||||
|
} else {
|
||||||
else
|
emit responseReady(parsed);
|
||||||
|
}
|
||||||
emit responseReady(parsed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Callback::processRPCCallback(json resp)
|
void Callback::processRPCCallback(json resp)
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
qDebug() << __func__ << ": caught an exception, ignoring: " << e.what();
|
qDebug() << __func__ << ": caught an exception, ignoring: " << e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reply.toUpper().trimmed() != "OK") {
|
if (reply.toUpper().trimmed() != "OK") {
|
||||||
qDebug() << "Lite server " << config->server << " is down, getting a random one";
|
qDebug() << "Lite server " << config->server << " is down, getting a random one";
|
||||||
config->server = Settings::getRandomServer();
|
config->server = Settings::getRandomServer();
|
||||||
@@ -237,8 +238,32 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
// 4. Finally attempt to save the wallet
|
// 4. Finally attempt to save the wallet
|
||||||
{
|
{
|
||||||
char* resp = litelib_execute("save", "");
|
QString reply = "";
|
||||||
QString reply = litelib_process_response(resp);
|
try {
|
||||||
|
char* resp = litelib_execute("save", "");
|
||||||
|
QString reply = litelib_process_response(resp);
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
qDebug() << __func__ << ": caught an exception, ignoring: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reply.toUpper().trimmed() != "OK") {
|
||||||
|
qDebug() << "Lite server " << config->server << " is down, getting a random one";
|
||||||
|
config->server = Settings::getRandomServer();
|
||||||
|
qDebug() << __func__ << ": new server is " << config->server;
|
||||||
|
// make a new connection to the new server
|
||||||
|
char* resp = litelib_initialize_new_from_phrase(config->dangerous,config->server.toStdString().c_str(),
|
||||||
|
seed.toStdString().c_str(), birthday, number);
|
||||||
|
reply = litelib_process_response(resp);
|
||||||
|
|
||||||
|
// retry with the new server
|
||||||
|
try {
|
||||||
|
resp = litelib_execute("save", "");
|
||||||
|
reply = litelib_process_response(resp);
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
qDebug() << __func__ << ": caught an exception with new server, something is fucky: " << e.what();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QByteArray ba_reply = reply.toUtf8();
|
QByteArray ba_reply = reply.toUtf8();
|
||||||
QJsonDocument jd_reply = QJsonDocument::fromJson(ba_reply);
|
QJsonDocument jd_reply = QJsonDocument::fromJson(ba_reply);
|
||||||
|
|||||||
Reference in New Issue
Block a user