Skip to content
Bitcoin Roots

v29.4-roots.2 · Commit 15: [PATCH 15/21] 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 9d7c17ac91152e0a32c9c09fda5b0f4bd4f14049..b2fb8e2b2c187992de08cc469b884bcd63ed02e5 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. The two line-number columns refer to before and after.

src/qt/rpcconsole.cpp CHANGED
@@ -1213,6 +1213,8 @@ void RPCConsole::updateDetailWidget()
1213
1213
  ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
1214
1214
  ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.m_last_ping_time));
1215
1215
  ui->peerMinPing->setText(GUIUtil::formatPingTime(stats->nodeStats.m_min_ping_time));
1216
+ ui->peerVersion->setText(ts.na);
1217
+ ui->peerSubversion->setText(ts.na);
1216
1218
  if (stats->nodeStats.nVersion) {
1217
1219
  ui->peerVersion->setText(QString::number(stats->nodeStats.nVersion));
1218
1220
  }
@@ -1241,8 +1243,10 @@ void RPCConsole::updateDetailWidget()
1241
1243
  }
1242
1244
  ui->peerMappedAS->setText(stats->nodeStats.m_mapped_as != 0 ? QString::number(stats->nodeStats.m_mapped_as) : ts.na);
1243
1245
 
1244
- // This check fails for example if the lock was busy and
1245
- // nodeStateStats couldn't be fetched.
1246
+ resetPeerStateStats();
1247
+
1248
+ // This check fails, for example, if the lock was busy and node state stats
1249
+ // could not be fetched.
1246
1250
  if (stats->fNodeStateStatsAvailable) {
1247
1251
  ui->timeoffset->setText(GUIUtil::formatTimeOffset(Ticks<std::chrono::seconds>(stats->nodeStateStats.time_offset)));
1248
1252
  ui->peerServices->setText(GUIUtil::formatServicesStr(stats->nodeStateStats.their_services));
@@ -1270,6 +1274,23 @@ void RPCConsole::updateDetailWidget()
1270
1274
  ui->peersTabRightPanel->show();
1271
1275
  }
1272
1276
 
1277
+ void RPCConsole::resetPeerStateStats()
1278
+ {
1279
+ // State stats can be unavailable when the non-blocking cs_main acquisition
1280
+ // loses a refresh race. Clear them first so a newly selected peer never
1281
+ // shows state from an earlier selection.
1282
+ ui->timeoffset->setText(ts.na);
1283
+ ui->peerServices->setText(ts.na);
1284
+ ui->peerSyncHeight->setText(ts.unknown);
1285
+ ui->peerCommonHeight->setText(ts.unknown);
1286
+ ui->peerHeight->setText(ts.unknown);
1287
+ ui->peerPingWait->setText(ts.na);
1288
+ ui->peerAddrRelayEnabled->setText(ts.na);
1289
+ ui->peerAddrProcessed->setText(ts.na);
1290
+ ui->peerAddrRateLimited->setText(ts.na);
1291
+ ui->peerRelayTxes->setText(ts.na);
1292
+ }
1293
+
1273
1294
  void RPCConsole::resizeEvent(QResizeEvent *event)
1274
1295
  {
1275
1296
  QWidget::resizeEvent(event);