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
@@ -604,6 +604,7 @@ void main() {
|
||||
() async {
|
||||
final store = ChannelMessageStore()..publicKeyHex = '1234567890';
|
||||
final channelIndex = 1;
|
||||
const channelId = '0123456789abcdef';
|
||||
|
||||
final rawPath = Uint8List(64)
|
||||
..[0] = 0xBB
|
||||
@@ -623,11 +624,11 @@ void main() {
|
||||
|
||||
final prefs = PrefsManager.instance;
|
||||
await prefs.setString(
|
||||
'${store.keyFor}$channelIndex',
|
||||
'${store.keyFor}_$channelId',
|
||||
jsonEncode(messageJson),
|
||||
);
|
||||
|
||||
final messages = await store.loadChannelMessages(channelIndex);
|
||||
final messages = await store.loadChannelMessages(channelId);
|
||||
expect(messages, hasLength(1));
|
||||
expect(messages.first.pathLength, equals(1));
|
||||
expect(
|
||||
|
||||
@@ -36,6 +36,8 @@ ChannelMessage _ch(
|
||||
channelIndex: 0,
|
||||
);
|
||||
|
||||
const _channelId = '0123456789abcdef';
|
||||
|
||||
void main() {
|
||||
final base = DateTime(2026, 10, 1, 12);
|
||||
|
||||
@@ -127,10 +129,10 @@ void main() {
|
||||
await _init();
|
||||
final store = ChannelMessageStore()..setPublicKeyHex = _device;
|
||||
final received = base.add(const Duration(seconds: 42));
|
||||
await store.saveChannelMessages(0, [
|
||||
await store.saveChannelMessages(_channelId, [
|
||||
_ch('one', timestamp: base, receivedAt: received),
|
||||
]);
|
||||
final loaded = await store.loadChannelMessages(0);
|
||||
final loaded = await store.loadChannelMessages(_channelId);
|
||||
expect(loaded.single.receivedAt, received);
|
||||
expect(loaded.single.timestamp, base);
|
||||
});
|
||||
@@ -167,14 +169,14 @@ void main() {
|
||||
'plainText': true,
|
||||
};
|
||||
await _init({
|
||||
'channel_messages_${_device.substring(0, 10)}0': jsonEncode([
|
||||
'channel_messages_${_device.substring(0, 10)}_$_channelId': jsonEncode([
|
||||
record('old', past),
|
||||
record('ahead', future),
|
||||
]),
|
||||
});
|
||||
final store = ChannelMessageStore()..setPublicKeyHex = _device;
|
||||
final before = DateTime.now();
|
||||
final loaded = await store.loadChannelMessages(0);
|
||||
final loaded = await store.loadChannelMessages(_channelId);
|
||||
expect(loaded, hasLength(2));
|
||||
expect(
|
||||
loaded[0].receivedAt.millisecondsSinceEpoch,
|
||||
|
||||
Reference in new issue
Block a user