From 4a39a7cd462ed072f85d00b625671e82bdab2fee Mon Sep 17 00:00:00 2001 From: PacoX Date: Tue, 19 May 2026 08:49:52 +0200 Subject: [PATCH] fix from copilot review + doc fix --- documentation/routing-paths.md | 7 ++++--- lib/helpers/path_helper.dart | 1 + lib/screens/channel_message_path_screen.dart | 10 ++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/documentation/routing-paths.md b/documentation/routing-paths.md index 1db0eed2..9d5d93df 100644 --- a/documentation/routing-paths.md +++ b/documentation/routing-paths.md @@ -15,6 +15,7 @@ The device capability determines the hash width (number of bytes per hop): | 1 byte | 256 | Single-byte node IDs | | 2 bytes | 65,536 | Medium meshes | | 3 bytes | 16.7M | Large networks | +| 4 bytes | 4.3G | Very large meshes / future-proofing | ### Device Capability Detection @@ -25,11 +26,11 @@ On device connection, the app reads the firmware capability to set `pathHashByte final modeRaw = firmwareBytes.length >= 82 ? (firmwareBytes[81] & 0xFF) : 0; -final mode = modeRaw.clamp(0, 2); -_pathHashByteWidth = mode + 1; // 1, 2, or 3 bytes per hop +final mode = modeRaw.clamp(0, 3); +_pathHashByteWidth = mode + 1; // 1, 2, 3, or 4 bytes per hop ``` -The current implementation intentionally clamps to modes `0..2`, so the supported hop width is `1..3` bytes. Do not document 4-byte hops unless the connector implementation is widened first. +The connector reads a single-mode byte and clamps to `0..3`, so the supported hop width is `1..4` bytes. UI code also clamps widths when rendering (typically to `1..4`) so 4-byte hops are handled end-to-end in the current codebase. ### Path Data Structure diff --git a/lib/helpers/path_helper.dart b/lib/helpers/path_helper.dart index 3109de90..f8e8f124 100644 --- a/lib/helpers/path_helper.dart +++ b/lib/helpers/path_helper.dart @@ -38,6 +38,7 @@ class PathHelper { /// - 1: Single byte per hop (256 unique nodes) /// - 2: Two bytes per hop (65K unique nodes) /// - 3: Three bytes per hop (16M unique nodes) + /// - 4: Four bytes per hop (4.3G unique nodes) static String resolvePathNames( List pathBytes, List allContacts, diff --git a/lib/screens/channel_message_path_screen.dart b/lib/screens/channel_message_path_screen.dart index df20f2b7..c7fa4ee5 100644 --- a/lib/screens/channel_message_path_screen.dart +++ b/lib/screens/channel_message_path_screen.dart @@ -47,14 +47,12 @@ class ChannelMessagePathScreen extends StatelessWidget { final hops = _buildPathHops(primaryPath, connector, l10n, hashByteWidth); final hasHopDetails = primaryPath.isNotEmpty; - // Convert path byte length to hop count using the packet width. + // Convert observed path byte length to hop count using the packet width. // Legacy messages fall back to the current connector width. + // Reported path length (V3+) is already stored as a hop count; preserve + // the negative flood sentinel when present. final observedHopCount = _hopCountFromBytes(primaryPath.length, hashByteWidth); - final reportedHopCount = message.pathLength == null - ? null - : (message.pathLength! < 0 - ? message.pathLength - : _hopCountFromBytes(message.pathLength!, hashByteWidth)); + final reportedHopCount = message.pathLength; final effectiveHopCount = observedHopCount > 0 ? observedHopCount : reportedHopCount;