Key per-channel storage by PSK-derived channel ID
Channel messages, settings, region, order and images were persisted by radio slot index, so a slot reused for a different channel inherited the old channel's history and settings (#359). - Channel.storageId: first 8 bytes of SHA-256("meshcore-channel:" + psk). - All per-channel stores key by channel ID; in-memory state stays by slot. - The connector keeps a slot -> channel ID map, diffs it against the saved map on every channel sync and reloads slots whose channel changed. - Queued channel frames wait until this session's map is confirmed. - One-shot per-radio migration from slot keys, using the cached channel list the legacy data was written under; rerun-safe if interrupted. - Deleting a channel clears its data; a channel removed elsewhere keeps its history and gets it back when re-added. A PSK edit keeps its place in the custom order. - Slots sharing a PSK share history and settings. - Image entries record their channel ID; a slot change resets that slot's in-progress reassembly.
This commit is contained in:
1 parent
d30744aa31
commit
679116ed03
24 files changed
+1794
-340
No files matched your search
@@ -633,6 +633,10 @@ enum ImageReassemblyFailureReason {
|
||||
|
||||
/// Dropped by [ImageReassembler.clear] (disconnect / new session).
|
||||
disconnected,
|
||||
|
||||
/// Dropped by [ImageReassembler.clearChannel] because the radio slot it
|
||||
/// arrived on now holds a different channel.
|
||||
channelChanged,
|
||||
}
|
||||
|
||||
/// A fully reassembled image.
|
||||
@@ -878,6 +882,34 @@ class ImageReassembler {
|
||||
}
|
||||
}
|
||||
|
||||
/// Drops every stream that arrived on [channelIndex], whose radio slot now
|
||||
/// holds a different channel, so a new image there can never be completed
|
||||
/// with the old channel's bytes. In-progress streams are reported through
|
||||
/// [onFailed] so their bubbles stop showing "receiving".
|
||||
void clearChannel(int channelIndex, {DateTime? now}) {
|
||||
final at = now ?? _clock();
|
||||
_recentlyCompleted.removeWhere(
|
||||
(key, _) => key.channelIndex == channelIndex,
|
||||
);
|
||||
final dropped = _pending.values
|
||||
.where((entry) => entry.key.channelIndex == channelIndex)
|
||||
.toList();
|
||||
for (final entry in dropped) {
|
||||
_pending.remove(entry.key);
|
||||
onFailed?.call(
|
||||
ImageReassemblyFailure(
|
||||
key: entry.key,
|
||||
total: entry.total,
|
||||
receivedDataChunks: entry.bodies.length,
|
||||
hadParity: entry.hasParity,
|
||||
firstSeen: entry.firstSeen,
|
||||
expiredAt: at,
|
||||
reason: ImageReassemblyFailureReason.channelChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Feeds one received GRP_DATA blob.
|
||||
///
|
||||
/// [now] overrides the clock for tests. Expired entries are swept first, so
|
||||
|
||||
Reference in new issue
Block a user