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
@@ -330,6 +330,40 @@ void main() {
|
||||
);
|
||||
expect(r.pendingCount, 2);
|
||||
});
|
||||
|
||||
test('clearChannel stops a reused slot finishing with old bytes', () {
|
||||
final oldSet = buildImageChunks(
|
||||
payload: payloadOf(300, seed: 1),
|
||||
metadata: stdMeta,
|
||||
senderPrefix: senderA,
|
||||
imgId: 9,
|
||||
);
|
||||
final newPayload = payloadOf(300, seed: 2);
|
||||
final newSet = buildImageChunks(
|
||||
payload: newPayload,
|
||||
metadata: stdMeta,
|
||||
senderPrefix: senderA,
|
||||
imgId: 9,
|
||||
);
|
||||
expect(newSet.dataChunkCount, greaterThanOrEqualTo(2));
|
||||
final failures = <ImageReassemblyFailure>[];
|
||||
final r = ImageReassembler(onFailed: failures.add);
|
||||
r.addChunk(oldSet.blobs[0], channelIndex: 3);
|
||||
r.addChunk(oldSet.blobs[0], channelIndex: 4);
|
||||
|
||||
r.clearChannel(3);
|
||||
expect(failures.single.key.channelIndex, 3);
|
||||
expect(
|
||||
failures.single.reason,
|
||||
ImageReassemblyFailureReason.channelChanged,
|
||||
);
|
||||
expect(r.pendingKeys.single.channelIndex, 4);
|
||||
|
||||
// Without the clear, these would complete with the old chunk 0.
|
||||
final dataBlobs = newSet.blobs.sublist(0, newSet.dataChunkCount);
|
||||
expect(feed(r, dataBlobs.sublist(1), channelIndex: 3), isNull);
|
||||
expect(feed(r, [dataBlobs[0]], channelIndex: 3)!.data, newPayload);
|
||||
});
|
||||
});
|
||||
|
||||
group('parity recovery', () {
|
||||
|
||||
Reference in new issue
Block a user