|
|
@ -10,6 +10,8 @@ |
|
|
|
#include "websockets.h" |
|
|
|
#include "Model/ChatItem.h" |
|
|
|
#include "DataStore/DataStore.h" |
|
|
|
#include <thread> |
|
|
|
|
|
|
|
|
|
|
|
ChatModel *chatModel = new ChatModel(); |
|
|
|
Chat *chat = new Chat(); |
|
|
@ -273,15 +275,28 @@ void Controller::noConnection() |
|
|
|
} |
|
|
|
|
|
|
|
/// This will refresh all the balance data from hushd
|
|
|
|
void Controller::refresh(bool force) |
|
|
|
{ |
|
|
|
qDebug()<< __func__; |
|
|
|
if (!zrpc->haveConnection()) |
|
|
|
return; |
|
|
|
#include <thread> |
|
|
|
|
|
|
|
void Controller::refresh(bool force) { |
|
|
|
qDebug() << __func__; |
|
|
|
|
|
|
|
int attempts = 0; |
|
|
|
const int max_attempts = 10; |
|
|
|
|
|
|
|
getInfoThenRefresh(force); |
|
|
|
while (!zrpc->haveConnection()) { |
|
|
|
if (attempts >= max_attempts) { |
|
|
|
qDebug() << "Max retry reached"; |
|
|
|
return; |
|
|
|
} |
|
|
|
qDebug() << "Waiting for connection... try : " << attempts + 1; |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts)); |
|
|
|
attempts++; |
|
|
|
} |
|
|
|
|
|
|
|
getInfoThenRefresh(force); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Controller::processInfo(const json& info) |
|
|
|
{ |
|
|
|
// Testnet?
|
|
|
@ -302,9 +317,19 @@ void Controller::processInfo(const json& info) |
|
|
|
|
|
|
|
void Controller::getInfoThenRefresh(bool force) |
|
|
|
{ |
|
|
|
qDebug()<< __func__; |
|
|
|
if (!zrpc->haveConnection()) |
|
|
|
return noConnection(); |
|
|
|
qDebug()<< __func__; |
|
|
|
int attempts = 0; |
|
|
|
int max_attempts = 10; |
|
|
|
|
|
|
|
while (!zrpc->haveConnection()) { |
|
|
|
if (attempts >= max_attempts) { |
|
|
|
return noConnection(); |
|
|
|
} |
|
|
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts)); |
|
|
|
attempts++; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool prevCallSucceeded = false; |
|
|
|
|
|
|
@ -630,8 +655,19 @@ void Controller::setLag(int lag) |
|
|
|
void Controller::refreshAddresses() |
|
|
|
{ |
|
|
|
qDebug()<< __func__; |
|
|
|
if (!zrpc->haveConnection()) |
|
|
|
return noConnection(); |
|
|
|
|
|
|
|
int attempts = 0; |
|
|
|
const int max_attempts = 10; |
|
|
|
|
|
|
|
while (!zrpc->haveConnection()) { |
|
|
|
if (attempts >= max_attempts) { |
|
|
|
qDebug() << "Max try reached"; |
|
|
|
return noConnection(); |
|
|
|
} |
|
|
|
qDebug() << "Waiting for connection... try : " << attempts + 1; |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts)); |
|
|
|
attempts++; |
|
|
|
} |
|
|
|
|
|
|
|
auto newzaddresses = new QList<QString>(); |
|
|
|
auto newtaddresses = new QList<QString>(); |
|
|
@ -885,8 +921,19 @@ void Controller::updateUIBalances() |
|
|
|
void Controller::refreshBalances() |
|
|
|
{ |
|
|
|
qDebug()<< __func__; |
|
|
|
if (!zrpc->haveConnection()) |
|
|
|
return noConnection(); |
|
|
|
|
|
|
|
int attempts = 0; |
|
|
|
const int max_attempts = 10; |
|
|
|
|
|
|
|
while (!zrpc->haveConnection()) { |
|
|
|
if (attempts >= max_attempts) { |
|
|
|
qDebug() << "Max try reached"; |
|
|
|
return noConnection(); |
|
|
|
} |
|
|
|
qDebug() << "Waiting for connection... try : " << attempts + 1; |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts)); |
|
|
|
attempts++; |
|
|
|
} |
|
|
|
|
|
|
|
// 1. Get the Balances
|
|
|
|
zrpc->fetchBalance([=] (json reply) { |
|
|
@ -961,8 +1008,19 @@ void printJsonValue(QTextStream& out, const nlohmann::json& j, int depth = 0) { |
|
|
|
|
|
|
|
void Controller::refreshTransactions() { |
|
|
|
qDebug()<< __func__; |
|
|
|
if (!zrpc->haveConnection()) |
|
|
|
return noConnection(); |
|
|
|
|
|
|
|
int attempts = 0; |
|
|
|
const int max_attempts = 10; |
|
|
|
|
|
|
|
while (!zrpc->haveConnection()) { |
|
|
|
if (attempts >= max_attempts) { |
|
|
|
qDebug() << "Max try reached"; |
|
|
|
return noConnection(); |
|
|
|
} |
|
|
|
qDebug() << "Waiting for connection... try : " << attempts + 1; |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts)); |
|
|
|
attempts++; |
|
|
|
} |
|
|
|
|
|
|
|
qDebug() << __func__ << ": fetchTransactions"; |
|
|
|
zrpc->fetchTransactions([=] (json reply) { |
|
|
@ -1562,8 +1620,19 @@ void Controller::checkForUpdate(bool silent) |
|
|
|
qDebug()<< __func__; |
|
|
|
// No checking for updates, needs testing with Gitea
|
|
|
|
return; |
|
|
|
if (!zrpc->haveConnection()) |
|
|
|
return noConnection(); |
|
|
|
|
|
|
|
int attempts = 0; |
|
|
|
const int max_attempts = 10; |
|
|
|
|
|
|
|
while (!zrpc->haveConnection()) { |
|
|
|
if (attempts >= max_attempts) { |
|
|
|
qDebug() << "Max try reached"; |
|
|
|
return noConnection(); |
|
|
|
} |
|
|
|
qDebug() << "Waiting for connection... try : " << attempts + 1; |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts)); |
|
|
|
attempts++; |
|
|
|
} |
|
|
|
|
|
|
|
QUrl cmcURL("https://git.hush.is/repos/MyHush/SilentDragonLite/releases"); |
|
|
|
|
|
|
@ -1651,8 +1720,19 @@ void Controller::checkForUpdate(bool silent) |
|
|
|
void Controller::refreshHUSHPrice() |
|
|
|
{ |
|
|
|
qDebug()<< __func__; |
|
|
|
if (!zrpc->haveConnection()) |
|
|
|
return; |
|
|
|
|
|
|
|
int attempts = 0; |
|
|
|
const int max_attempts = 10; |
|
|
|
|
|
|
|
while (!zrpc->haveConnection()) { |
|
|
|
if (attempts >= max_attempts) { |
|
|
|
qDebug() << "Max try reached"; |
|
|
|
return noConnection(); |
|
|
|
} |
|
|
|
qDebug() << "Waiting for connection... try : " << attempts + 1; |
|
|
|
std::this_thread::sleep_for(std::chrono::seconds(2 * attempts)); |
|
|
|
attempts++; |
|
|
|
} |
|
|
|
|
|
|
|
// TODO: use/render all this data
|
|
|
|
QUrl cmcURL("https://api.coingecko.com/api/v3/simple/price?ids=hush&vs_currencies=btc%2Cusd%2Ceur%2Ceth%2Cgbp%2Ccny%2Cjpy%2Crub%2Ccad%2Csgd%2Cchf%2Cinr%2Caud%2Cinr&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true"); |
|
|
|