Commit cbeb36c
committed
lsps0: Fix LSPSDateTime::duration_since to saturate at zero on clock skew
Replace abs_diff with a saturating subtraction so that duration_since
returns Duration::ZERO when the reference timestamp is in the apparent
future (e.g. due to clock skew or monotonicity violations). Callers
using the result as an age — prune_terminal_orders (LSPS1),
prune_terminal_channels (LSPS2), and the stale-webhook and cooldown
checks (LSPS5) — no longer risk spuriously large values triggering
premature pruning or incorrect cooldown expiry.
Two unit tests are added to document the contract.1 parent f73b81a commit cbeb36c
1 file changed
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
260 | 264 | | |
261 | | - | |
262 | | - | |
| 265 | + | |
| 266 | + | |
263 | 267 | | |
264 | 268 | | |
265 | 269 | | |
| |||
981 | 985 | | |
982 | 986 | | |
983 | 987 | | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
984 | 1004 | | |
0 commit comments