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 0 : #define FD_DEFAULT_SLOTS_PER_EPOCH ( 432000UL ) 8 : #define FD_DEFAULT_SHREDS_PER_EPOCH ( ( 1 << 15UL ) * FD_DEFAULT_SLOTS_PER_EPOCH ) 9 111 : #define FD_SLOT_NULL ( ULONG_MAX ) 10 0 : #define FD_SHRED_IDX_NULL ( UINT_MAX ) 11 : 12 123 : #define FD_FUNK_KEY_TYPE_ACC ((uchar)1) 13 57 : #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 42 : uchar const * in ) { 42 42 : if( FD_UNLIKELY( !in ) ) { 43 3 : strcpy( out, "<NULL>"); 44 39 : } else { 45 39 : fd_base58_encode_32( in, NULL, out ); 46 39 : } 47 42 : return out; 48 42 : } 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_exec_slot_ctx; 76 : typedef struct fd_exec_slot_ctx fd_exec_slot_ctx_t; 77 : 78 : struct fd_exec_txn_ctx; 79 : typedef struct fd_exec_txn_ctx fd_exec_txn_ctx_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_borrowed_account; 91 : typedef struct fd_borrowed_account fd_borrowed_account_t; 92 : 93 : struct fd_txn_account; 94 : typedef struct fd_txn_account fd_txn_account_t; 95 : 96 : /* fd_rawtxn_b_t is a convenience type to store a pointer to a 97 : serialized transaction. Should probably be removed in the future. */ 98 : 99 : struct fd_rawtxn_b { 100 : void * raw; 101 : ushort txn_sz; 102 : }; 103 : typedef struct fd_rawtxn_b fd_rawtxn_b_t; 104 : 105 : FD_PROTOTYPES_BEGIN 106 : 107 : /* fd_acct_addr_cstr converts the given Solana address into a base58- 108 : encoded cstr. Returns cstr. On return cstr contains a string with 109 : length in [32,44] (excluding NULL terminator). */ 110 : 111 : static inline char * 112 : fd_acct_addr_cstr( char cstr[ FD_BASE58_ENCODED_32_SZ ], 113 6 : uchar const addr[ 32 ] ) { 114 : return fd_base58_encode_32( addr, NULL, cstr ); 115 6 : } 116 : 117 : FD_PROTOTYPES_END 118 : 119 : #endif /* HEADER_fd_src_flamenco_fd_flamenco_base_h */