diag(client): _onStats/setLivePing 打点,定位延迟为何不回写 node.ping
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import '../services/api_config.dart';
|
||||
import '../services/latency_probe.dart';
|
||||
import 'auth_provider.dart';
|
||||
import 'connection_provider.dart';
|
||||
import '../bridge/log.dart';
|
||||
|
||||
// ── 节点列表 AsyncNotifier ────────────────────────────────────────
|
||||
|
||||
@@ -86,14 +87,24 @@ class NodesNotifier extends AsyncNotifier<List<Node>> {
|
||||
/// 回写某节点的实测延迟(ms)。连接态由 ConnectionController 用内核 urltest 回填连接节点,
|
||||
/// 让「连接页延迟」与「节点列表延迟」同源(都读 node.ping)、显示一致。ms<=0 忽略。
|
||||
void setLivePing(String uuid, int ms) {
|
||||
if (ms <= 0 || _disposed) return;
|
||||
if (ms <= 0 || _disposed) {
|
||||
logLine('Ping', 'setLivePing SKIP ms=$ms disposed=$_disposed');
|
||||
return;
|
||||
}
|
||||
final list = state.valueOrNull;
|
||||
if (list == null) return;
|
||||
if (list == null) {
|
||||
logLine('Ping', 'setLivePing no-list');
|
||||
return;
|
||||
}
|
||||
var changed = false;
|
||||
final updated = [
|
||||
for (final n in list)
|
||||
if (n.uuid == uuid && n.ping != ms) (() { changed = true; return n.copyWith(ping: ms); })() else n
|
||||
];
|
||||
final match = list.any((n) => n.uuid == uuid);
|
||||
logLine('Ping',
|
||||
'setLivePing ms=$ms match=$match changed=$changed '
|
||||
'nodes=[${list.map((n) => "${n.code}:${n.ping}").join(",")}]');
|
||||
if (changed) state = AsyncData(updated);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user