From df874f848a42f3bb7a7c4a7afd6431f1007de4a2 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 4 Nov 2022 21:25:51 +0000 Subject: [PATCH 1/4] net: Ensure CNode.cleanSubVer is always assigned before nVersion --- src/net_processing.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index eca6263392c..4a6e9615f7c 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3224,6 +3224,10 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, // Change version const int greatest_common_version = std::min(nVersion, PROTOCOL_VERSION); pfrom.SetCommonVersion(greatest_common_version); + { + LOCK(pfrom.m_subver_mutex); + pfrom.cleanSubVer = cleanSubVer; + } pfrom.nVersion = nVersion; const CNetMsgMaker msg_maker(greatest_common_version); @@ -3246,10 +3250,6 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, pfrom.m_has_all_wanted_services = HasAllDesirableServiceFlags(nServices); peer->m_their_services = nServices; pfrom.SetAddrLocal(addrMe); - { - LOCK(pfrom.m_subver_mutex); - pfrom.cleanSubVer = cleanSubVer; - } peer->m_starting_height = starting_height; // We only initialize the m_tx_relay data structure if: From 238f042ff2ca377edac61fdb925f266aacf1bd52 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 4 Nov 2022 21:27:24 +0000 Subject: [PATCH 2/4] Bugfix: GUI: Peers: If subversion is actually blank, show blank --- src/qt/rpcconsole.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index a07686ab2b7..12f608e7a1c 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -1180,8 +1180,6 @@ void RPCConsole::updateDetailWidget() ui->timeoffset->setText(GUIUtil::formatTimeOffset(stats->nodeStats.nTimeOffset)); if (stats->nodeStats.nVersion) { ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion)); - } - if (!stats->nodeStats.cleanSubVer.empty()) { ui->peerSubversion->setText(QString::fromStdString(stats->nodeStats.cleanSubVer)); } ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type, /*prepend_direction=*/true)); From 35fbd4886e4abde98fd07fa4f89beea8b4efc47b Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 4 Nov 2022 21:48:57 +0000 Subject: [PATCH 3/4] Bugfix: GUI: Peers: When selecting a new peer, reset fields to N/A before loading data Without this, !fNodeStateStatsAvailable will leave fields with the data of the previously selected peer --- src/qt/forms/debugwindow.ui | 2 +- src/qt/rpcconsole.cpp | 14 +++++++++++++- src/qt/rpcconsole.h | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/debugwindow.ui b/src/qt/forms/debugwindow.ui index ead977296a2..f56ffe4052e 100644 --- a/src/qt/forms/debugwindow.ui +++ b/src/qt/forms/debugwindow.ui @@ -1034,7 +1034,7 @@ 426 - + diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 12f608e7a1c..61d44cfad20 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -704,7 +704,10 @@ void RPCConsole::setClientModel(ClientModel *model, int bestblock_height, int64_ connect(ui->peerWidget, &QTableView::customContextMenuRequested, this, &RPCConsole::showPeersTableContextMenu); // peer table signal handling - update peer details when selecting new node - connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &RPCConsole::updateDetailWidget); + connect(ui->peerWidget->selectionModel(), &QItemSelectionModel::selectionChanged, [this] { + resetDetailWidget(); + updateDetailWidget(); + }); connect(model->getPeerTableModel(), &QAbstractItemModel::dataChanged, [this] { updateDetailWidget(); }); // set up ban table @@ -1147,6 +1150,15 @@ void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut) ui->lblBytesOut->setText(GUIUtil::formatBytes(totalBytesOut)); } +void RPCConsole::resetDetailWidget() +{ + for (int row = 0; QLayoutItem * const item = ui->peerDetailsGrid->itemAtPosition(row, 1); ++row) { + QLabel * const value_label = qobject_cast(item->widget()); + if (!value_label) continue; + value_label->setText(ts.na); + } +} + void RPCConsole::updateDetailWidget() { const QList selected_peers = GUIUtil::getEntryData(ui->peerWidget, PeerTableModel::NetNodeId); diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index a3c713e9669..c9b9bad2c9b 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -105,6 +105,8 @@ private Q_SLOTS: void showOrHideBanTableIfRequired(); /** clear the selected node */ void clearSelectedNode(); + /** reset all fields in UI detailed information to N/A */ + void resetDetailWidget(); /** show detailed information on ui about selected node */ void updateDetailWidget(); From cfe5bbe6ccd4cac703e3a6d28f05b05c562a54e3 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 4 Nov 2022 21:49:42 +0000 Subject: [PATCH 4/4] Bugfix: GUI: Peers: Peers without any permissions are "None", not "N/A" --- src/qt/rpcconsole.cpp | 2 +- src/qt/rpcconsole.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 61d44cfad20..65836b94cea 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -1197,7 +1197,7 @@ void RPCConsole::updateDetailWidget() ui->peerConnectionType->setText(GUIUtil::ConnectionTypeToQString(stats->nodeStats.m_conn_type, /*prepend_direction=*/true)); ui->peerNetwork->setText(GUIUtil::NetworkToQString(stats->nodeStats.m_network)); if (stats->nodeStats.m_permission_flags == NetPermissionFlags::None) { - ui->peerPermissions->setText(ts.na); + ui->peerPermissions->setText(ts.no_permissions); } else { QStringList permissions; for (const auto& permission : NetPermissions::ToStrings(stats->nodeStats.m_permission_flags)) { diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index c9b9bad2c9b..a0c5089726f 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -142,7 +142,7 @@ public Q_SLOTS: private: struct TranslatedStrings { const QString yes{tr("Yes")}, no{tr("No")}, to{tr("To")}, from{tr("From")}, - ban_for{tr("Ban for")}, na{tr("N/A")}, unknown{tr("Unknown")}; + ban_for{tr("Ban for")}, na{tr("N/A")}, unknown{tr("Unknown")}, no_permissions{tr("None")}; } const ts; void startExecutor();