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: 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 a07686ab2b7..65836b94cea 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); @@ -1180,14 +1192,12 @@ 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)); 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 a3c713e9669..a0c5089726f 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(); @@ -140,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();