Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_sysvar_fd_clock_h 2 : #define HEADER_fd_src_flamenco_runtime_sysvar_fd_clock_h 3 : 4 : /* The clock sysvar provides an approximate measure of network time. */ 5 : 6 : #include "fd_sysvar_base.h" 7 : #include "../../types/fd_types.h" 8 : 9 : /* https://github.com/solana-labs/solana/blob/8f2c8b8388a495d2728909e30460aa40dcc5d733/sdk/program/src/clock.rs#L10 */ 10 : #define FD_SYSVAR_CLOCK_DEFAULT_TICKS_PER_SECOND ( 160UL ) 11 0 : #define FD_SYSVAR_CLOCK_DEFAULT_HASHES_PER_TICK (12500UL) 12 : 13 : /* FD_SYSVAR_CLOCK_STAKE_WEIGHTS_MAX specifies the max number of stake 14 : weights processed in a clock update. */ 15 : 16 : #define FD_SYSVAR_CLOCK_STAKE_WEIGHTS_MAX (10240UL) 17 : 18 : FD_PROTOTYPES_BEGIN 19 : 20 : /* The clock sysvar provides an approximate measure of network time. */ 21 : 22 : /* fd_sysvar_clock_init initializes the sysvar account to genesis state. */ 23 : 24 : void 25 : fd_sysvar_clock_init( fd_bank_t * bank, 26 : fd_funk_t * funk, 27 : fd_funk_txn_xid_t const * xid, 28 : fd_capture_ctx_t * capture_ctx ); 29 : 30 : /* fd_sysvar_clock_update updates the clock sysvar account. Runs 31 : fd_calculate_stake_weighted_timestamp under the hood. Should be 32 : called at the start of every slot before execution commences. Takes 33 : in a pointer to the parent_epoch, where *parent_epoch is the epoch of 34 : the parent slot. parent_epoch = NULL is used for genesis bootup. 35 : Crashes the process with FD_LOG_ERR on failure. */ 36 : 37 : void 38 : fd_sysvar_clock_update( fd_bank_t * bank, 39 : fd_funk_t * funk, 40 : fd_funk_txn_xid_t const * xid, 41 : fd_capture_ctx_t * capture_ctx, 42 : fd_spad_t * spad, 43 : ulong const * parent_epoch ); 44 : 45 : /* Writes the current value of the clock sysvar to funk. */ 46 : 47 : void 48 : fd_sysvar_clock_write( fd_bank_t * bank, 49 : fd_funk_t * funk, 50 : fd_funk_txn_xid_t const * xid, 51 : fd_capture_ctx_t * capture_ctx, 52 : fd_sol_sysvar_clock_t * clock ); 53 : 54 : /* fd_sysvar_clock_read reads the current value of the rent sysvar from 55 : funk. If the account doesn't exist in funk or if the account 56 : has zero lamports, this function returns NULL. */ 57 : 58 : fd_sol_sysvar_clock_t * 59 : fd_sysvar_clock_read( fd_funk_t * funk, 60 : fd_funk_txn_xid_t const * xid, 61 : fd_sol_sysvar_clock_t * clock ); 62 : 63 : FD_PROTOTYPES_END 64 : 65 : #endif /* HEADER_fd_src_flamenco_runtime_sysvar_fd_clock_h */