upd - fix and format

This commit is contained in:
HDDen
2026-06-14 01:36:49 +03:00
parent d61eaaaff1
commit e92d215582
7 changed files with 32 additions and 18 deletions
+6 -5
View File
@@ -21,10 +21,10 @@ class PathHopResolver {
if (contact.type != advTypeRepeater && contact.type != advTypeRoom) { if (contact.type != advTypeRepeater && contact.type != advTypeRoom) {
continue; continue;
} }
final prefix = PathHelper.formatHopHex(contact.publicKey.sublist(0, width)); final prefix = PathHelper.formatHopHex(
candidatesByPrefix contact.publicKey.sublist(0, width),
.putIfAbsent(prefix, () => <Contact>[]) );
.add(contact); candidatesByPrefix.putIfAbsent(prefix, () => <Contact>[]).add(contact);
} }
for (final candidates in candidatesByPrefix.values) { for (final candidates in candidatesByPrefix.values) {
candidates.sort((a, b) => b.lastSeen.compareTo(a.lastSeen)); candidates.sort((a, b) => b.lastSeen.compareTo(a.lastSeen));
@@ -39,7 +39,8 @@ class PathHopResolver {
var previousPosition = endpoint; var previousPosition = endpoint;
for (final index in indexes) { for (final index in indexes) {
final candidates = candidatesByPrefix[PathHelper.formatHopHex(hops[index])]; final candidates =
candidatesByPrefix[PathHelper.formatHopHex(hops[index])];
if (candidates == null || candidates.isEmpty) continue; if (candidates == null || candidates.isEmpty) continue;
var bestIndex = 0; var bestIndex = 0;
+1 -1
View File
@@ -2591,7 +2591,7 @@ class AppLocalizationsDe extends AppLocalizations {
@override @override
String get repeater_pathHashModeHelper => String get repeater_pathHashModeHelper =>
'Bytes, die zur Kodierung der ID dieses Repeaters in Flood-Pfad-/Schleifen-Erkennung-Tags verwendet werden. 0 = 1 Byte (256 IDs, bis zu 64 Hops), 1 = 2 Bytes (65.000 IDs, bis zu 32 Hops), 2 = 3 Bytes (16 Millionen IDs, bis zu 21 Hops). Firmware vor v1.14 verwendet immer 1-Byte-Pfade; ab v1.14 können 2- oder 3-Byte-Pfade eingestellt werden.'; 'Bytes, die zur Kodierung der ID dieses Repeaters in Flood-Pfad-/Schleifen-Erkennung-Tags verwendet werden. 0 = 1 Byte (256 IDs, bis zu 64 Hops), 1 = 2 Bytes (65.000 IDs, bis zu 32 Hops), 2 = 3 Bytes (16 Millionen IDs, bis zu 21 Hops). Firmware-Versionen 1.13 und älter verwenden mehrstellige Pfade ab Version 1.14+ wird nur ein Pfad erstellt, sobald das Netzwerk aktiv ist.';
@override @override
String get repeater_txDelay => 'Flood-TX-Verzögerung'; String get repeater_txDelay => 'Flood-TX-Verzögerung';
+1 -1
View File
@@ -2591,7 +2591,7 @@ class AppLocalizationsEs extends AppLocalizations {
@override @override
String get repeater_pathHashModeHelper => String get repeater_pathHashModeHelper =>
'Bytes utilizados para codificar el ID de este repetidor en las etiquetas de ruta flood/detección de bucles. 0=1 byte (256 IDs, hasta 64 saltos), 1=2 bytes (65.000 IDs, hasta 32 saltos), 2=3 bytes (16 millones de IDs, hasta 21 saltos). El firmware anterior a v1.14 siempre usaba rutas de 1 byte; v1.14 y posteriores pueden configurarse para rutas de 2 o 3 bytes.'; 'Bytes utilizados para codificar el ID de este repetidor en las etiquetas de ruta/detección de bucles. 0=1 byte (256 IDs, hasta 64 saltos), 1=2 bytes (65.000 IDs, hasta 32 saltos), 2=3 bytes (16 millones de IDs, hasta 21 saltos). Las versiones 1.13 y anteriores de firmware eliminan rutas de múltiples bytes; solo se detectan una vez que la red está activa en la versión 1.14 o posterior.';
@override @override
String get repeater_txDelay => 'Retraso TX por inundación'; String get repeater_txDelay => 'Retraso TX por inundación';
+1 -1
View File
@@ -2602,7 +2602,7 @@ class AppLocalizationsFr extends AppLocalizations {
@override @override
String get repeater_pathHashModeHelper => String get repeater_pathHashModeHelper =>
'Octets utilisés pour encoder l\'ID de ce répéteur dans les balises de chemin flood/détection de boucle. 0=1 octet (256 ID, jusqu\'à 64 sauts), 1=2 octets (65 000 ID, jusqu\'à 32 sauts), 2=3 octets (16 millions d\'ID, jusqu\'à 21 sauts). Le firmware antérieur à v1.14 utilisait toujours des chemins d\'1 octet; v1.14 et les versions ultérieures peuvent être configurées pour des chemins de 2 ou 3 octets.'; 'Octets utilisés pour encoder l\'ID de ce routeur dans les balises de détection de flux/boucles. 0 = 1 octet (256 ID, jusqu\'à 64 sauts), 1 = 2 octets (65 000 ID, jusqu\'à 32 sauts), 2 = 3 octets (16 millions d\'ID, jusqu\'à 21 sauts). Les versions 1.13 et antérieures utilisent des chemins multi-octets ; à partir de la version 1.14, cela n\'est plus nécessaire.';
@override @override
String get repeater_txDelay => 'Délai de transmission en flood'; String get repeater_txDelay => 'Délai de transmission en flood';
+16 -3
View File
@@ -515,6 +515,11 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
final displayPathHashWidth = final displayPathHashWidth =
message.pathHashWidth ?? message.pathHashWidth ??
context.read<MeshCoreConnector>().pathHashByteWidth; context.read<MeshCoreConnector>().pathHashByteWidth;
final displayHopCount = _displayHopCount(
displayPath,
displayPathHashWidth,
message.pathLength,
);
// Bubble colors outgoing uses MeshPalette.me / meBorder / meInk. // Bubble colors outgoing uses MeshPalette.me / meBorder / meInk.
final bubbleColor = isOutgoing final bubbleColor = isOutgoing
@@ -665,9 +670,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
children: [ children: [
RouteChip( RouteChip(
isDirect: (message.pathLength ?? -1) >= 0, isDirect: (message.pathLength ?? -1) >= 0,
hops: (message.pathLength ?? -1) >= 0 hops: displayHopCount,
? message.pathLength
: null,
), ),
const SizedBox(width: 4), const SizedBox(width: 4),
Text( Text(
@@ -1564,6 +1567,16 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
).map(PathHelper.formatHopHex).join(','); ).map(PathHelper.formatHopHex).join(',');
} }
int? _displayHopCount(
Uint8List pathBytes,
int pathHashByteWidth,
int? fallbackPathLength,
) {
if ((fallbackPathLength ?? -1) < 0) return null;
if (pathBytes.isEmpty) return fallbackPathLength;
return PathHelper.splitPathBytes(pathBytes, pathHashByteWidth).length;
}
/// Deterministic name-to-hue mapping consistent with [AvatarCircle]. /// Deterministic name-to-hue mapping consistent with [AvatarCircle].
Color _colorForName(String name) { Color _colorForName(String name) {
const hues = [ const hues = [
+4 -6
View File
@@ -156,11 +156,11 @@ class ChannelMessagePathScreen extends StatelessWidget {
}) { }) {
final l10n = context.l10n; final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme; final scheme = Theme.of(context).colorScheme;
final routeChip = message.pathLength == null final routeChip = effectiveHopCount == null
? null ? null
: message.pathLength! < 0 : effectiveHopCount < 0
? const RouteChip(isDirect: false) ? const RouteChip(isDirect: false)
: RouteChip(isDirect: true, hops: message.pathLength); : RouteChip(isDirect: true, hops: effectiveHopCount);
return MeshCard( return MeshCard(
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
@@ -1887,9 +1887,7 @@ Uint8List _orientPathBytes(
}) { }) {
if (!reverse || pathBytes.isEmpty) return pathBytes; if (!reverse || pathBytes.isEmpty) return pathBytes;
final hops = PathHelper.splitPathBytes(pathBytes, hashByteWidth); final hops = PathHelper.splitPathBytes(pathBytes, hashByteWidth);
return Uint8List.fromList([ return Uint8List.fromList([for (final hop in hops.reversed) ...hop]);
for (final hop in hops.reversed) ...hop,
]);
} }
int _hopCountFromBytes(int byteCount, int hashByteWidth) { int _hopCountFromBytes(int byteCount, int hashByteWidth) {
+3 -1
View File
@@ -1321,7 +1321,9 @@ class _MapScreenState extends State<MapScreen> {
(contact.type == advTypeRepeater || contact.type == advTypeRoom) && (contact.type == advTypeRepeater || contact.type == advTypeRoom) &&
contact.publicKey.length >= overlapHopWidth && contact.publicKey.length >= overlapHopWidth &&
overlapPrefixes.contains( overlapPrefixes.contains(
PathHelper.formatHopHex(contact.publicKey.sublist(0, overlapHopWidth)), PathHelper.formatHopHex(
contact.publicKey.sublist(0, overlapHopWidth),
),
); );
void addNode(Contact contact, {bool dot = false}) { void addNode(Contact contact, {bool dot = false}) {