mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-03-31 05:25:49 +00:00
20 lines
1020 B
Markdown
20 lines
1020 B
Markdown
# Simplex.FileTransfer.Server.Stats
|
|
|
|
> XFTP server statistics: IORef-based counters with backward-compatible persistence.
|
|
|
|
**Source**: [`FileTransfer/Server/Stats.hs`](../../../../../src/Simplex/FileTransfer/Server/Stats.hs)
|
|
|
|
## Non-obvious behavior
|
|
|
|
### 1. setFileServerStats is not thread safe
|
|
|
|
`setFileServerStats` directly writes to IORefs without synchronization. It is explicitly intended for server startup only (restoring from backup file), before any concurrent threads are running.
|
|
|
|
### 2. Backward-compatible parsing
|
|
|
|
The `strP` parser uses `opt` for newer fields, defaulting missing fields to 0. This allows reading stats files from older server versions that don't include fields like `filesBlocked` or `fileDownloadAcks`.
|
|
|
|
### 3. PeriodStats for download tracking
|
|
|
|
`filesDownloaded` uses `PeriodStats` (not a simple `IORef Int`) to track unique file downloads over time periods (day/week/month). This enables the CSV stats log to report distinct files downloaded per period, not just total download count.
|