LCOV - code coverage report
Current view: top level - flamenco/runtime/sysvar - fd_sysvar_clock.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 1 0.0 %
Date: 2026-07-11 05:27:41 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_clock_h
       2             : #define HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_clock_h
       3             : 
       4             : /* The clock sysvar provides an approximate measure of network time. */
       5             : 
       6             : #include "../../fd_flamenco_base.h"
       7             : #include "../../accdb/fd_accdb.h"
       8             : #include "fd_sysvar_base.h"
       9             : 
      10             : /* https://github.com/solana-labs/solana/blob/8f2c8b8388a495d2728909e30460aa40dcc5d733/sdk/program/src/clock.rs#L10 */
      11             : #define FD_SYSVAR_CLOCK_DEFAULT_TICKS_PER_SECOND ( 160UL )
      12           0 : #define FD_SYSVAR_CLOCK_DEFAULT_HASHES_PER_TICK  (12500UL)
      13             : 
      14             : /* ts_est_ele_t is a temporary struct used for sorting vote accounts by
      15             :    last vote timestamp for clock sysvar calculation. */
      16             : struct ts_est_ele {
      17             :   long        timestamp;
      18             :   fd_w_u128_t stake; /* should really be fine as ulong, but we match Agave */
      19             : };
      20             : typedef struct ts_est_ele ts_est_ele_t;
      21             : 
      22             : /* The clock sysvar provides an approximate measure of network time. */
      23             : 
      24             : /* fd_sysvar_clock_init initializes the sysvar account to genesis state. */
      25             : 
      26             : FD_PROTOTYPES_BEGIN
      27             : 
      28             : void
      29             : fd_sysvar_clock_init( fd_bank_t *        bank,
      30             :                       fd_accdb_t *       accdb,
      31             :                       fd_capture_ctx_t * capture_ctx );
      32             : 
      33             : /* fd_sysvar_clock_read reads the current value of the clock sysvar at
      34             :    fork_id into *clock.  Returns clock on success, NULL if the account
      35             :    is missing or too small. */
      36             : 
      37             : fd_sol_sysvar_clock_t *
      38             : fd_sysvar_clock_read( fd_accdb_t *            accdb,
      39             :                       fd_accdb_fork_id_t      fork_id,
      40             :                       fd_sol_sysvar_clock_t * clock );
      41             : 
      42             : /* fd_sysvar_clock_update updates the clock sysvar account.  Runs
      43             :    fd_calculate_stake_weighted_timestamp under the hood.  Should be
      44             :    called at the start of every slot before execution commences.  Takes
      45             :    in a pointer to the parent_epoch, where *parent_epoch is the epoch of
      46             :    the parent slot.  parent_epoch = NULL is used for genesis bootup.
      47             :    Crashes the process with FD_LOG_ERR on failure. */
      48             : 
      49             : void
      50             : fd_sysvar_clock_update( fd_bank_t *          bank,
      51             :                         fd_accdb_t *         accdb,
      52             :                         fd_capture_ctx_t *   capture_ctx,
      53             :                         fd_runtime_stack_t * runtime_stack,
      54             :                         ulong const *        parent_epoch );
      55             : 
      56             : FD_PROTOTYPES_END
      57             : 
      58             : #endif /* HEADER_fd_src_flamenco_runtime_sysvar_fd_sysvar_clock_h */

Generated by: LCOV version 1.14