Browse Source

Add notarized txid and lag

pull/45/head
Jonathan "Duke" Leto 5 years ago
parent
commit
a50a3dfe8b
  1. 47
      src/mainwindow.ui
  2. 18
      src/rpc.cpp

47
src/mainwindow.ui

@ -936,6 +936,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="7" column="0">
<widget class="QLabel" name="notarizedhashlabel"> <widget class="QLabel" name="notarizedhashlabel">
<property name="text"> <property name="text">
@ -957,6 +958,52 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="0">
<widget class="QLabel" name="notarizedtxidlabel">
<property name="text">
<string>Notarized txid</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QLabel" name="notarizedtxidvalue">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="notarizedtxidspacer">
<property name="text">
<string>|</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="laglabel">
<property name="text">
<string>Notarized Lag</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLabel" name="lagvalue">
<property name="text">
<string>Loading...</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="lagspacer">
<property name="text">
<string>|</string>
</property>
</widget>
</item>
<item row="3" column="2"> <item row="3" column="2">
<widget class="QLabel" name="solrate"> <widget class="QLabel" name="solrate">
<property name="text"> <property name="text">

18
src/rpc.cpp

@ -39,6 +39,7 @@ RPC::RPC(MainWindow* main) {
// Set up a timer to refresh the UI every few seconds // Set up a timer to refresh the UI every few seconds
timer = new QTimer(main); timer = new QTimer(main);
QObject::connect(timer, &QTimer::timeout, [=]() { QObject::connect(timer, &QTimer::timeout, [=]() {
//qDebug() << "Refreshing main UI";
refresh(); refresh();
}); });
timer->start(Settings::updateSpeed); timer->start(Settings::updateSpeed);
@ -46,6 +47,7 @@ RPC::RPC(MainWindow* main) {
// Set up the timer to watch for tx status // Set up the timer to watch for tx status
txTimer = new QTimer(main); txTimer = new QTimer(main);
QObject::connect(txTimer, &QTimer::timeout, [=]() { QObject::connect(txTimer, &QTimer::timeout, [=]() {
//qDebug() << "Watching tx status";
watchTxStatus(); watchTxStatus();
}); });
// Start at every 10s. When an operation is pending, this will change to every second // Start at every 10s. When an operation is pending, this will change to every second
@ -79,14 +81,14 @@ void RPC::setEZcashd(QProcess* p) {
} }
} }
// Called when a connection to zcashd is available. // Called when a connection to hushd is available.
void RPC::setConnection(Connection* c) { void RPC::setConnection(Connection* c) {
if (c == nullptr) return; if (c == nullptr) return;
delete conn; delete conn;
this->conn = c; this->conn = c;
ui->statusBar->showMessage("Ready!"); ui->statusBar->showMessage("Ready! Thank you for helping secure the Hush network by running a full node.");
// See if we need to remove the reindex/rescan flags from the zcash.conf file // See if we need to remove the reindex/rescan flags from the zcash.conf file
auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation(); auto zcashConfLocation = Settings::getInstance()->getZcashdConfLocation();
@ -94,7 +96,7 @@ void RPC::setConnection(Connection* c) {
Settings::removeFromZcashConf(zcashConfLocation, "reindex"); Settings::removeFromZcashConf(zcashConfLocation, "reindex");
// Refresh the UI // Refresh the UI
refreshZECPrice(); refreshZECPrice();
checkForUpdate(); checkForUpdate();
// Force update, because this might be coming from a settings update // Force update, because this might be coming from a settings update
@ -527,6 +529,9 @@ void RPC::refresh(bool force) {
void RPC::getInfoThenRefresh(bool force) { void RPC::getInfoThenRefresh(bool force) {
//qDebug() << "getinfo";
if (conn == nullptr) if (conn == nullptr)
return noConnection(); return noConnection();
@ -552,10 +557,14 @@ void RPC::getInfoThenRefresh(bool force) {
int curBlock = reply["blocks"].get<json::number_integer_t>(); int curBlock = reply["blocks"].get<json::number_integer_t>();
int version = reply["version"].get<json::number_integer_t>(); int version = reply["version"].get<json::number_integer_t>();
int notarized = reply["notarized"].get<json::number_integer_t>(); int notarized = reply["notarized"].get<json::number_integer_t>();
int lag = curBlock - notarized;
QString ntzhash = QString::fromStdString( reply["notarizedhash"].get<json::string_t>() ); QString ntzhash = QString::fromStdString( reply["notarizedhash"].get<json::string_t>() );
QString ntztxid = QString::fromStdString( reply["notarizedtxid"].get<json::string_t>() );
Settings::getInstance()->setZcashdVersion(version); Settings::getInstance()->setZcashdVersion(version);
ui->notarizedhashvalue->setText( ntzhash ); ui->notarizedhashvalue->setText( ntzhash );
ui->notarizedtxidvalue->setText( ntztxid );
ui->lagvalue->setText( QString::number(lag) );
if ( force || (curBlock != lastBlock) ) { if ( force || (curBlock != lastBlock) ) {
// Something changed, so refresh everything. // Something changed, so refresh everything.
@ -970,6 +979,8 @@ void RPC::watchTxStatus() {
} }
void RPC::checkForUpdate(bool silent) { void RPC::checkForUpdate(bool silent) {
qDebug() << "checking for updates";
if (conn == nullptr) if (conn == nullptr)
return noConnection(); return noConnection();
@ -977,7 +988,6 @@ void RPC::checkForUpdate(bool silent) {
QNetworkRequest req; QNetworkRequest req;
req.setUrl(cmcURL); req.setUrl(cmcURL);
QNetworkReply *reply = conn->restclient->get(req); QNetworkReply *reply = conn->restclient->get(req);
QObject::connect(reply, &QNetworkReply::finished, [=] { QObject::connect(reply, &QNetworkReply::finished, [=] {

Loading…
Cancel
Save