fix(grpc-data): H4 review 5+6 — AdminUI display: 'unavailable' without handshake evidence; every bit rendered
HistoryServed reads 'unavailable' when neither features nor variants were reported. Features() and DroppedBits() render every set bit across all 32 (bit 31 included), named when known and hex otherwise, so an unknown bit is never hidden beside a known one (#919).
This commit is contained in:
@@ -26,17 +26,23 @@ public static class DataConnectionDiagnostics
|
||||
"auth-failed" => "Authentication failed", "backoff" => "Backoff", _ => "Unavailable"
|
||||
};
|
||||
/// <summary>H4: the features the last handshake negotiated; "none (v1)" when the peer negotiated nothing optional.</summary>
|
||||
/// <remarks>Every set bit is shown — a name when this AdminUI knows it, hex otherwise (H4 review: never hidden by a known one).</remarks>
|
||||
public static string Features(DataFeatures? features) => features switch
|
||||
{
|
||||
null => "unavailable",
|
||||
DataFeatures.None => "none (v1 behaviour)",
|
||||
{ } f => string.Join(", ", Enum.GetValues<DataFeatures>().Where(x => x != DataFeatures.None && f.HasFlag(x)).Select(x => x.ToString())
|
||||
.DefaultIfEmpty($"0x{(int)f:X}")),
|
||||
{ } f => Bits((uint)(int)f, bit => Enum.IsDefined((DataFeatures)(int)bit) ? ((DataFeatures)(int)bit).ToString() : null),
|
||||
};
|
||||
|
||||
/// <summary>Each set bit of <paramref name="value"/> across all 32, low to high: its name, or hex when unnamed.</summary>
|
||||
private static string Bits(uint value, Func<uint, string?> name) =>
|
||||
string.Join(", ", Enumerable.Range(0, 32).Select(i => 1u << i).Where(bit => (value & bit) != 0)
|
||||
.Select(bit => name(bit) ?? $"0x{bit:X}"));
|
||||
|
||||
/// <summary>H4: the history variants and aggregate count the origin advertised to this caller.</summary>
|
||||
public static string HistoryServed(DataConnectionDiagnosticsSnapshot row) =>
|
||||
row.HistoryVariants is not { } variants ? "not advertised"
|
||||
row.NegotiatedFeatures is null && row.HistoryVariants is null ? "unavailable"
|
||||
: row.HistoryVariants is not { } variants ? "not advertised"
|
||||
: variants.Count == 0 ? "advertised, no variant granted"
|
||||
: string.Join(", ", variants) + (row.HistoryAggregateCount is { } n ? $" ({n} aggregates)" : "");
|
||||
|
||||
@@ -53,8 +59,7 @@ public static class DataConnectionDiagnostics
|
||||
{
|
||||
null => "unavailable",
|
||||
DataOperations.None => "none",
|
||||
{ } b => string.Join(", ", Enumerable.Range(0, 31).Select(i => (DataOperations)(1 << i)).Where(x => b.HasFlag(x))
|
||||
.Select(x => Enum.IsDefined(x) ? DataOperationAuthoring.Label(x) : $"0x{(int)x:X}")),
|
||||
{ } b => Bits((uint)(int)b, bit => Enum.IsDefined((DataOperations)(int)bit) ? DataOperationAuthoring.Label((DataOperations)(int)bit) : null),
|
||||
};
|
||||
|
||||
/// <summary>#919: true when the drop deserves the "node build is older than the authored feature" hint.</summary>
|
||||
|
||||
Reference in New Issue
Block a user