Skip to content
Bitcoin Roots

v30.3-roots.1 · Commit 15: [PATCH 15/68] fix(qt): clear stale peer details on refresh

src/qt/rpcconsole.cpp

Before: src/qt/rpcconsole.cpp · After: src/qt/rpcconsole.cpp

File metadata
index d6d2be7b3934bca497bc3ad3dfe11219f39506f5..dfb540bad04658a671593414f5fe32d6e8fcedda 100644

Download original patch · Release notes

Diff rows 1–43 of 43. Line numbers refer to the original before/after files.

+ Added− RemovedUnmarked lines are context.

Scroll the code area horizontally to read long lines. Before is on the left; after is on the right. Unified view fits narrow screens more easily.

src/qt/rpcconsole.cpp CHANGED
@@ -1172,6 +1172,8 @@ void RPCConsole::updateDetailWidget()
1172
  ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
1173
  ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.m_last_ping_time));
1174
  ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.m_min_ping_time));
 
 
1175
  if (stats->nodeStats.nVersion) {
1176
  ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
1177
  }
@@ -1200,8 +1202,10 @@ void RPCConsole::updateDetailWidget()
1200
  }
1201
  ui->peerMappedAS->setText(stats->nodeStats.m_mapped_as != 0 ? QString::number(stats->nodeStats.m_mapped_as) : ts.na);
1202
 
1203
- // This check fails for example if the lock was busy and
1204
- // nodeStateStats couldn't be fetched.
 
 
1205
  if (stats->fNodeStateStatsAvailable) {
1206
  ui->timeoffset->setText(GUIUtil::formatTimeOffset(Ticks<std::chrono::seconds>(stats->nodeStateStats.time_offset)));
1207
  ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStateStats.their_services));
@@ -1229,6 +1233,23 @@ void RPCConsole::updateDetailWidget()
1229
  ui->peersTabRightPanel->show();
1230
  }
1231
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1232
  void RPCConsole::resizeEvent(QResizeEvent *event)
1233
  {
1234
  QWidget::resizeEvent(event);
 
1172
  ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
1173
  ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.m_last_ping_time));
1174
  ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.m_min_ping_time));
1175
+ ui->peerVersion->setText(ts.na);
1176
+ ui->peerSubversion->setText(ts.na);
1177
  if (stats->nodeStats.nVersion) {
1178
  ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
1179
  }
 
1202
  }
1203
  ui->peerMappedAS->setText(stats->nodeStats.m_mapped_as != 0 ? QString::number(stats->nodeStats.m_mapped_as) : ts.na);
1204
 
1205
+ resetPeerStateStats();
1206
+
1207
+ // This check fails, for example, if the lock was busy and node state stats
1208
+ // could not be fetched.
1209
  if (stats->fNodeStateStatsAvailable) {
1210
  ui->timeoffset->setText(GUIUtil::formatTimeOffset(Ticks<std::chrono::seconds>(stats->nodeStateStats.time_offset)));
1211
  ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStateStats.their_services));
 
1233
  ui->peersTabRightPanel->show();
1234
  }
1235
 
1236
+ void RPCConsole::resetPeerStateStats()
1237
+ {
1238
+ // State stats can be unavailable when the non-blocking cs_main acquisition
1239
+ // loses a refresh race. Clear them first so a newly selected peer never
1240
+ // shows state from an earlier selection.
1241
+ ui->timeoffset->setText(ts.na);
1242
+ ui->peerServices->setText(ts.na);
1243
+ ui->peerSyncHeight->setText(ts.unknown);
1244
+ ui->peerCommonHeight->setText(ts.unknown);
1245
+ ui->peerHeight->setText(ts.unknown);
1246
+ ui->peerPingWait->setText(ts.na);
1247
+ ui->peerAddrRelayEnabled->setText(ts.na);
1248
+ ui->peerAddrProcessed->setText(ts.na);
1249
+ ui->peerAddrRateLimited->setText(ts.na);
1250
+ ui->peerRelayTxes->setText(ts.na);
1251
+ }
1252
+
1253
  void RPCConsole::resizeEvent(QResizeEvent *event)
1254
  {
1255
  QWidget::resizeEvent(event);