LCOV - code coverage report
Current view: top level - flamenco - fd_flamenco_base.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 27 33 81.8 %
Date: 2025-08-05 05:04:49 Functions: 6 648 0.9 %

          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             : #include "types/fd_cast.h"
       6             : 
       7             : #define FD_DEFAULT_SLOTS_PER_EPOCH   ( 432000UL )
       8             : #define FD_DEFAULT_SHREDS_PER_EPOCH  ( ( 1 << 15UL ) * FD_DEFAULT_SLOTS_PER_EPOCH )
       9         273 : #define FD_SLOT_NULL                 ( ULONG_MAX )
      10           0 : #define FD_SHRED_IDX_NULL            ( UINT_MAX )
      11             : 
      12        5166 : #define FD_FUNK_KEY_TYPE_ACC       ((uchar)1)
      13         165 : #define FD_FUNK_KEY_TYPE_ELF_CACHE ((uchar)2)
      14             : 
      15             : /* CLUSTER_VERSION is the default value for the cluster version
      16             :    in the epoch context. This value will foll forward to the
      17             :    latest version.
      18             : */
      19           0 : #define FD_DEFAULT_AGAVE_CLUSTER_VERSION_MAJOR 2
      20           0 : #define FD_DEFAULT_AGAVE_CLUSTER_VERSION_MINOR 0
      21           0 : #define FD_DEFAULT_AGAVE_CLUSTER_VERSION_PATCH 0
      22             : 
      23             : #if FD_HAS_ALLOCA
      24             : 
      25             : /* FD_BASE58_ENC_{32,64}_ALLOCA is a shorthand for fd_base58_encode_{32,64},
      26             :    including defining a temp buffer.  With additional support for passing
      27             :    NULL.  Useful for printf-like functions.
      28             :    Example:
      29             : 
      30             :     fd_pubkey_t pk = ... ;
      31             :     printf("%s", FD_BASE58_ENC_32_ALLOCA( pk ) );
      32             : 
      33             :    The temp buffer is allocated on the stack and therefore invalidated
      34             :    when the function this is used in returns.  NULL will result in
      35             :    "<NULL>".
      36             :    Do NOT use this marco in a long loop or a recursive function.
      37             :    */
      38             : 
      39             : static inline char *
      40             : fd_base58_enc_32_fmt( char *        out,
      41        1623 :                       uchar const * in ) {
      42        1623 :   if( FD_UNLIKELY( !in ) ) {
      43           3 :     strcpy( out, "<NULL>");
      44        1620 :   } else {
      45        1620 :     fd_base58_encode_32( in, NULL, out );
      46        1620 :   }
      47        1623 :   return out;
      48        1623 : }
      49             : 
      50           6 : #define FD_BASE58_ENC_32_ALLOCA( x ) __extension__({                   \
      51           6 :   char * _out = fd_alloca_check( 1UL, FD_BASE58_ENCODED_32_SZ );       \
      52           6 :   fd_base58_enc_32_fmt( _out, (uchar const *)(x) );                    \
      53           6 : })
      54             : 
      55             : static inline char *
      56             : fd_base58_enc_64_fmt( char *        out,
      57           6 :                       uchar const * in ) {
      58           6 :   if( FD_UNLIKELY( !in ) ) {
      59           3 :     strcpy( out, "<NULL>");
      60           3 :   } else {
      61           3 :     fd_base58_encode_64( in, NULL, out );
      62           3 :   }
      63           6 :   return out;
      64           6 : }
      65             : 
      66           6 : #define FD_BASE58_ENC_64_ALLOCA( x ) __extension__({                   \
      67           6 :   char * _out = fd_alloca_check( 1UL, FD_BASE58_ENCODED_64_SZ );       \
      68           6 :   fd_base58_enc_64_fmt( _out, (uchar const *)(x) );                    \
      69           6 : })
      70             : 
      71             : #endif /* FD_HAS_ALLOCA */
      72             : 
      73             : /* Forward declarations */
      74             : 
      75             : struct fd_bank;
      76             : typedef struct fd_bank fd_bank_t;
      77             : 
      78             : struct fd_exec_slot_ctx;
      79             : typedef struct fd_exec_slot_ctx fd_exec_slot_ctx_t;
      80             : 
      81             : struct fd_exec_txn_ctx;
      82             : typedef struct fd_exec_txn_ctx fd_exec_txn_ctx_t;
      83             : 
      84             : struct fd_exec_instr_ctx;
      85             : typedef struct fd_exec_instr_ctx fd_exec_instr_ctx_t;
      86             : 
      87             : struct fd_acc_mgr;
      88             : typedef struct fd_acc_mgr fd_acc_mgr_t;
      89             : 
      90             : struct fd_capture_ctx;
      91             : typedef struct fd_capture_ctx fd_capture_ctx_t;
      92             : 
      93             : struct fd_borrowed_account;
      94             : typedef struct fd_borrowed_account fd_borrowed_account_t;
      95             : 
      96             : struct fd_txn_account;
      97             : typedef struct fd_txn_account fd_txn_account_t;
      98             : 
      99             : /* fd_rawtxn_b_t is a convenience type to store a pointer to a
     100             :    serialized transaction.  Should probably be removed in the future. */
     101             : 
     102             : struct fd_rawtxn_b {
     103             :   void * raw;
     104             :   ushort txn_sz;
     105             : };
     106             : typedef struct fd_rawtxn_b fd_rawtxn_b_t;
     107             : 
     108             : FD_PROTOTYPES_BEGIN
     109             : 
     110             : /* fd_acct_addr_cstr converts the given Solana address into a base58-
     111             :    encoded cstr.  Returns cstr.  On return cstr contains a string with
     112             :    length in [32,44] (excluding NULL terminator). */
     113             : 
     114             : static inline char *
     115             : fd_acct_addr_cstr( char        cstr[ FD_BASE58_ENCODED_32_SZ ],
     116           0 :                    uchar const addr[ 32 ] ) {
     117             :   return fd_base58_encode_32( addr, NULL, cstr );
     118           0 : }
     119             : 
     120             : FD_PROTOTYPES_END
     121             : 
     122             : #endif /* HEADER_fd_src_flamenco_fd_flamenco_base_h */

Generated by: LCOV version 1.14