merge
This commit is contained in:
57
src/rpc.cpp
57
src/rpc.cpp
@@ -470,7 +470,7 @@ void RPC::getInfoThenRefresh(bool force) {
|
||||
};
|
||||
|
||||
// Connected, so display checkmark.
|
||||
QIcon i(":/icons/res/connected.png");
|
||||
QIcon i(":/icons/res/connected.gif");
|
||||
main->statusIcon->setPixmap(i.pixmap(16, 16));
|
||||
|
||||
static int lastBlock = 0;
|
||||
@@ -899,3 +899,58 @@ void RPC::shutdownZcashd() {
|
||||
// Wait for the zcash process to exit.
|
||||
d.exec();
|
||||
}
|
||||
|
||||
|
||||
// Fetch the Z-board topics list
|
||||
void RPC::getZboardTopics(std::function<void(QMap<QString, QString>)> cb) {
|
||||
if (conn == nullptr)
|
||||
return noConnection();
|
||||
|
||||
QUrl cmcURL("http://z-board.net/listTopics");
|
||||
|
||||
QNetworkRequest req;
|
||||
req.setUrl(cmcURL);
|
||||
|
||||
QNetworkReply *reply = conn->restclient->get(req);
|
||||
|
||||
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
||||
reply->deleteLater();
|
||||
|
||||
try {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
auto parsed = json::parse(reply->readAll(), nullptr, false);
|
||||
if (!parsed.is_discarded() && !parsed["error"]["message"].is_null()) {
|
||||
qDebug() << QString::fromStdString(parsed["error"]["message"]);
|
||||
}
|
||||
else {
|
||||
qDebug() << reply->errorString();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
auto all = reply->readAll();
|
||||
|
||||
auto parsed = json::parse(all, nullptr, false);
|
||||
if (parsed.is_discarded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QMap<QString, QString> topics;
|
||||
for (const json& item : parsed["topics"].get<json::array_t>()) {
|
||||
if (item.find("addr") == item.end() || item.find("topicName") == item.end())
|
||||
return;
|
||||
|
||||
QString addr = QString::fromStdString(item["addr"].get<json::string_t>());
|
||||
QString topic = QString::fromStdString(item["topicName"].get<json::string_t>());
|
||||
|
||||
topics.insert(topic, addr);
|
||||
}
|
||||
|
||||
cb(topics);
|
||||
}
|
||||
catch (...) {
|
||||
// If anything at all goes wrong, just set the price to 0 and move on.
|
||||
qDebug() << QString("Caught something nasty");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user