Coverage / crates/spectra-core/src/hlc.rs 100.0%
31 of 31 lines run, 6 of 8 functions · run #17 on main · run missed
| 1 | //! The hybrid logical clock on every event (spec §9.1), with Oxygen's drift | |
| 2 | //! bound (oxygen spec §6.4): observing a remote time never moves this clock | |
| 3 | //! more than five minutes ahead of the local wall clock. | |
| 4 | | |
| 5 | use Mutex; | |
| 6 | ||
| 7 | /// How far ahead of the local clock an observed time may move ours. | |
| 8 | pub const MAX_DRIFT_MS: u64 = 5 * 60 * 1000; | |
| 9 | ||
| 10 | /// A hybrid logical clock reading: wall milliseconds and a counter. | |
| 11 | | |
| 12 | | |
| 13 | | |
| 14 | | |
| 15 | | |
| 16 | ||
| 17 | /// The clock: monotonic across calls, whatever the wall clock does. | |
| 18 | | |
| 19 | | |
| 20 | | |
| 21 | | |
| 22 | ||
| 23 | | |
| 24 | | |
| 25 | 148× | |
| 26 | 148× | |
| 27 | 148× | |
| 28 | | |
| 29 | | |
| 30 | 12147× | |
| 31 | 12147× | |
| 32 | 12147× | |
| 33 | 2182× | |
| 34 | | |
| 35 | 9965× | |
| 36 | | |
| 37 | 12147× | |
| 38 | 12147× | |
| 39 | | |
| 40 | | |
| 41 | | |
| 42 | | |
| 43 | 1× | |
| 44 | 1× | |
| 45 | 1× | |
| 46 | 1× | |
| 47 | 1× | |
| 48 | 1× | |
| 49 | 1× | |
| 50 | 1× | |
| 51 | | |
| 52 | ||
| 53 | | |
| 54 | | |
| 55 | | |
| 56 | | |
| 57 | | |
| 58 | 1× | |
| 59 | 1× | |
| 60 | 1× | |
| 61 | 1× | |
| 62 | 1× | |
| 63 | 1× | |
| 64 | 1× | |
| 65 | 1× | |
| 66 | | |
| 67 | | |
| 68 | 1× | |
| 69 | 1× | |
| 70 | 1× | |
| 71 | 1× | |
| 72 | 1× | |
| 73 | |