Try another server if current is down when saving wallet via a rescan
This commit is contained in:
@@ -217,6 +217,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
} 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();
|
||||
@@ -237,8 +238,32 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
// 4. Finally attempt to save the wallet
|
||||
{
|
||||
char* resp = litelib_execute("save", "");
|
||||
QString reply = litelib_process_response(resp);
|
||||
QString reply = "";
|
||||
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();
|
||||
QJsonDocument jd_reply = QJsonDocument::fromJson(ba_reply);
|
||||
|
||||
Reference in New Issue
Block a user