PR review modif + packet aware

This commit is contained in:
PacoX
2026-05-17 15:50:25 +02:00
parent 87b0fd6fc7
commit d6647f4701
17 changed files with 200 additions and 100 deletions
+11 -5
View File
@@ -163,12 +163,18 @@ class ChannelMessage {
final hasPath = (flags & 0x01) != 0;
reader.skipBytes(1); // Skip reserved byte
channelIdx = reader.readByte();
pathLen = reader.readInt8();
txtType = reader.readByte();
if (hasPath && pathLen > 0) {
reader.rewind(); // Rewind to read path length again for pathBytes
pathBytes = reader.readBytes(pathLen);
final pathByte = reader.readUInt8();
// pathByte packs: top 2 bits = hash width mode, low 6 bits = hop count
final packetPathHashWidth = ((pathByte & 0xC0) >> 6) + 1;
final hopCount = pathByte & 0x3F;
pathLen = hopCount;
// If a path is present, read hopCount * width bytes
if (hasPath && hopCount > 0) {
final totalPathBytes = hopCount * packetPathHashWidth;
pathBytes = reader.readBytes(totalPathBytes);
}
// After consuming optional path bytes, read the text type byte.
txtType = reader.readByte();
} else {
channelIdx = reader.readByte();
pathLen = reader.readInt8();
+1 -1
View File
@@ -119,7 +119,7 @@ class Contact {
String pathFormattedIdList(int hashByteWidth) {
final pathBytes = pathBytesForDisplay;
if (pathBytes.isEmpty) return '';
final w = hashByteWidth.clamp(1, 8);
final w = hashByteWidth.clamp(1, 4);
final parts = <String>[];
for (int i = 0; i < pathBytes.length; i += w) {
final end = (i + w) <= pathBytes.length ? (i + w) : pathBytes.length;