5 releases (3 stable)

new 2.1.2 Nov 22, 2024
2.1.1 Nov 16, 2024
2.1.0 Oct 29, 2024
0.0.2 Oct 18, 2024
0.0.1 Jul 2, 2024

#193 in Magic Beans

Download history 14/week @ 2024-09-14 8/week @ 2024-09-21 18/week @ 2024-09-28 2/week @ 2024-10-05 65/week @ 2024-10-12 137/week @ 2024-10-19 2541/week @ 2024-10-26 6016/week @ 2024-11-02 6896/week @ 2024-11-09 9929/week @ 2024-11-16

25,443 downloads per month
Used in 143 crates (6 directly)

Apache-2.0

14KB
136 lines

Information about the network's clock, ticks, slots, etc.

Time in Solana is marked primarily by slots, which occur approximately every 400 milliseconds, and are numbered sequentially. For every slot, a leader is chosen from the validator set, and that leader is expected to produce a new block, though sometimes leaders may fail to do so. Blocks can be identified by their slot number, and some slots do not contain a block.

An approximation of the passage of real-world time can be calculated by multiplying a number of slots by DEFAULT_MS_PER_SLOT, which is a constant target time for the network to produce slots. Note though that this method suffers a variable amount of drift, as the network does not produce slots at exactly the target rate, and the greater number of slots being calculated for, the greater the drift. Epochs cannot be used this way as they contain variable numbers of slots.

The network's current view of the real-world time can always be accessed via Clock::unix_timestamp, which is produced by an oracle derived from the validator set.

Dependencies

~0.6–6MB
~38K SLoC