SMP router specs

This commit is contained in:
Evgeny @ SimpleX Chat
2026-03-12 11:29:18 +00:00
parent 09d55de115
commit 260ffb1a9d
33 changed files with 715 additions and 0 deletions
@@ -0,0 +1,17 @@
# Simplex.Messaging.Server.StoreLog.ReadWrite
> Store log replay (read) and snapshot (write) for STM queue store.
**Source**: [`ReadWrite.hs`](../../../../../../src/Simplex/Messaging/Server/StoreLog/ReadWrite.hs)
## readQueueStore — error-tolerant replay
Log replay (`readQueueStore`) processes each line independently. Parse errors are printed to stdout and skipped. Operation errors (e.g., queue not found during `SecureQueue` replay) are logged and skipped. A deleted queue encountered during replay (`queueRec` is `Nothing`) logs a warning but does not fail. This means a corrupted log line only loses that single operation, not the entire store.
## NewService ID validation
During replay, `getCreateService` may return a different `serviceId` than the one stored in the log (if the service cert already exists with a different ID). This is logged as an error but does not abort replay — the store continues with the ID it assigned. This handles the case where a store log was manually edited or partially corrupted.
## writeQueueStore — services before queues
`writeQueueStore` writes services first, then queues. Order matters: when the log is replayed, service IDs must already exist before queues reference them via `rcvServiceId`/`ntfServiceId`.
@@ -0,0 +1,7 @@
# Simplex.Messaging.Server.StoreLog.Types
> GADT wrapper for file handles with type-level IOMode enforcement.
**Source**: [`Types.hs`](../../../../../../src/Simplex/Messaging/Server/StoreLog/Types.hs)
No non-obvious behavior. See source. Constructors are intentionally not exported — callers must use `openWriteStoreLog`/`openReadStoreLog`.