LCOV - code coverage report
Current view: top level - flamenco - fd_flamenco_base.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 15 19 78.9 %
Date: 2026-06-29 05:51:35 Functions: 24 1564 1.5 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_fd_flamenco_base_h
       2             : #define HEADER_fd_src_flamenco_fd_flamenco_base_h
       3             : 
       4             : #include "../ballet/base58/fd_base58.h"
       5             : 
       6             : /* fd_w_u128 is a wrapped "uint128" type providing basic 128-bit
       7             :    unsigned int functionality even if the compile target does not
       8             :    natively support uint128. */
       9             : 
      10             : union __attribute__((packed)) fd_w_u128 {
      11             :   uchar uc[16];
      12             :   ulong ul[2];
      13             : # ifdef __SIZEOF_INT128__
      14             :   uint128 ud;
      15             : # endif
      16             : };
      17             : 
      18             : typedef union fd_w_u128 fd_w_u128_t;
      19             : 
      20             : /* 32-byte container */
      21             : 
      22       51789 : #define FD_HASH_FOOTPRINT   (32UL)
      23        2085 : #define FD_PUBKEY_FOOTPRINT FD_HASH_FOOTPRINT
      24             : union __attribute__((packed)) fd_hash {
      25             :   uchar hash[ FD_HASH_FOOTPRINT ];
      26             :   uchar key [ FD_HASH_FOOTPRINT ]; // Making fd_hash and fd_pubkey interchangeable
      27             : 
      28             :   // Generic type specific accessors
      29             :   ulong  ul  [ FD_HASH_FOOTPRINT / sizeof(ulong)  ];
      30             :   uint   ui  [ FD_HASH_FOOTPRINT / sizeof(uint)   ];
      31             :   ushort us  [ FD_HASH_FOOTPRINT / sizeof(ushort) ];
      32             :   uchar  uc  [ FD_HASH_FOOTPRINT                  ];
      33             : };
      34             : typedef union fd_hash fd_hash_t;
      35             : typedef union fd_hash fd_pubkey_t;
      36             : 
      37             : FD_FN_PURE static inline int
      38             : fd_hash_eq( fd_hash_t const * a,
      39      192759 :             fd_hash_t const * b ) {
      40      192759 :   return 0==memcmp( a, b, sizeof(fd_hash_t) );
      41      192759 : }
      42             : 
      43             : FD_FN_PURE static inline int
      44             : fd_hash_eq1( fd_hash_t a,
      45         453 :              fd_hash_t b ) {
      46         453 :   return
      47         453 :     ( a.ul[0]==b.ul[0] ) & ( a.ul[1]==b.ul[1] ) &
      48         453 :     ( a.ul[2]==b.ul[2] ) & ( a.ul[3]==b.ul[3] );
      49         453 : }
      50             : 
      51             : FD_FN_PURE static inline int
      52          24 : fd_hash_check_zero( fd_hash_t const * _x ) {
      53          24 :   return !( (_x)->ul[0] | (_x)->ul[1] | (_x)->ul[2] | (_x)->ul[3] );
      54          24 : }
      55             : 
      56           0 : #define fd_pubkey_check_zero fd_hash_check_zero
      57        8409 : #define fd_pubkey_eq         fd_hash_eq
      58             : 
      59             : /* 64-byte container */
      60             : 
      61             : union fd_signature {
      62             :   uchar uc[ 64 ];
      63             :   ulong ul[  8 ];
      64             : };
      65             : typedef union fd_signature fd_signature_t;
      66             : 
      67             : FD_FN_PURE static inline int
      68             : fd_signature_eq( fd_signature_t const * a,
      69           0 :                  fd_signature_t const * b ) {
      70           0 :   return 0==memcmp( a, b, sizeof(fd_signature_t) );
      71           0 : }
      72             : 
      73             : /* Forward declarations */
      74             : 
      75             : struct fd_bank;
      76             : typedef struct fd_bank fd_bank_t;
      77             : 
      78             : struct fd_banks;
      79             : typedef struct fd_banks fd_banks_t;
      80             : 
      81             : struct fd_exec_instr_ctx;
      82             : typedef struct fd_exec_instr_ctx fd_exec_instr_ctx_t;
      83             : 
      84             : struct fd_acc_mgr;
      85             : typedef struct fd_acc_mgr fd_acc_mgr_t;
      86             : 
      87             : struct fd_capture_ctx;
      88             : typedef struct fd_capture_ctx fd_capture_ctx_t;
      89             : 
      90             : struct fd_dump_proto_ctx;
      91             : typedef struct fd_dump_proto_ctx fd_dump_proto_ctx_t;
      92             : 
      93             : struct fd_txn_dump_ctx;
      94             : typedef struct fd_txn_dump_ctx fd_txn_dump_ctx_t;
      95             : 
      96             : struct fd_borrowed_account;
      97             : typedef struct fd_borrowed_account fd_borrowed_account_t;
      98             : 
      99             : union fd_features;
     100             : typedef union fd_features fd_features_t;
     101             : 
     102             : struct fd_progcache;
     103             : typedef struct fd_progcache fd_progcache_t;
     104             : 
     105             : struct fd_runtime_stack;
     106             : typedef struct fd_runtime_stack fd_runtime_stack_t;
     107             : 
     108             : struct fd_vote_stakes;
     109             : typedef struct fd_vote_stakes fd_vote_stakes_t;
     110             : 
     111             : struct fd_runtime;
     112             : typedef struct fd_runtime fd_runtime_t;
     113             : 
     114             : struct fd_txn_in;
     115             : typedef struct fd_txn_in fd_txn_in_t;
     116             : 
     117             : struct fd_txn_out;
     118             : typedef struct fd_txn_out fd_txn_out_t;
     119             : 
     120             : struct fd_log_collector;
     121             : typedef struct fd_log_collector fd_log_collector_t;
     122             : 
     123             : struct fd_genesis;
     124             : typedef struct fd_genesis fd_genesis_t;
     125             : 
     126             : struct fd_stake_rewards;
     127             : typedef struct fd_stake_rewards fd_stake_rewards_t;
     128             : 
     129             : struct fd_top_votes;
     130             : typedef struct fd_top_votes fd_top_votes_t;
     131             : 
     132             : /* Misc types */
     133             : 
     134           6 : #define FD_EPOCH_CREDITS_MAX (64UL)
     135             : struct fd_epoch_credits {
     136             :   uchar  pubkey[32];
     137             :   ulong  cnt;
     138             :   ulong  base_credits;
     139             :   ushort epoch             [ FD_EPOCH_CREDITS_MAX ];
     140             :   uint   credits_delta     [ FD_EPOCH_CREDITS_MAX ];
     141             :   uint   prev_credits_delta[ FD_EPOCH_CREDITS_MAX ];
     142             : };
     143             : typedef struct fd_epoch_credits fd_epoch_credits_t;
     144             : 
     145             : struct fd_stashed_commission {
     146             :   uchar  pubkey[32];
     147             :   ushort commission;
     148             : };
     149             : typedef struct fd_stashed_commission fd_stashed_commission_t;
     150             : 
     151             : struct fd_hard_fork {
     152             :   ulong slot;
     153             :   ulong cnt; /* number of hard forks in that slot */
     154             : };
     155             : typedef struct fd_hard_fork fd_hard_fork_t;
     156             : 
     157             : FD_PROTOTYPES_BEGIN
     158             : 
     159             : struct fd_fee_rate_governor {
     160             :   ulong target_lamports_per_signature;
     161             :   ulong target_signatures_per_slot;
     162             :   ulong min_lamports_per_signature;
     163             :   ulong max_lamports_per_signature;
     164             :   uchar burn_percent;
     165             : };
     166             : typedef struct fd_fee_rate_governor fd_fee_rate_governor_t;
     167             : 
     168             : struct fd_inflation {
     169             :   double initial;
     170             :   double terminal;
     171             :   double taper;
     172             :   double foundation;
     173             :   double foundation_term;
     174             :   double unused;
     175             : };
     176             : typedef struct fd_inflation fd_inflation_t;
     177             : 
     178             : #endif /* HEADER_fd_src_flamenco_fd_flamenco_base_h */

Generated by: LCOV version 1.14