Line data Source code
1 : #ifndef HEADER_fd_src_discof_restore_utils_fd_slot_delta_parser_h 2 : #define HEADER_fd_src_discof_restore_utils_fd_slot_delta_parser_h 3 : 4 : #include "../../../util/fd_util_base.h" 5 : 6 : struct fd_slot_delta_parser_private; 7 : typedef struct fd_slot_delta_parser_private fd_slot_delta_parser_t; 8 : 9 : struct fd_sstxncache_entry { 10 : ulong slot; 11 : uchar blockhash[ 32UL ]; 12 : uchar txnhash[ 20UL ]; 13 : uchar result; 14 : }; 15 : typedef struct fd_sstxncache_entry fd_sstxncache_entry_t; 16 : 17 3 : #define FD_SLOT_DELTA_MAX_ENTRIES (300UL) 18 : 19 : struct fd_slot_entry { 20 : ulong slot; 21 : 22 : struct { 23 : ulong next; 24 : } pool; 25 : 26 : struct { 27 : ulong next; 28 : ulong prev; 29 : } map; 30 : }; 31 : typedef struct fd_slot_entry fd_slot_entry_t; 32 : 33 : #define POOL_NAME slot_pool 34 6 : #define POOL_T fd_slot_entry_t 35 : #define POOL_IDX_T ulong 36 900 : #define POOL_NEXT pool.next 37 : #include "../../../util/tmpl/fd_pool.c" 38 : 39 : #define MAP_NAME slot_set 40 108 : #define MAP_KEY slot 41 : #define MAP_KEY_T ulong 42 54 : #define MAP_ELE_T fd_slot_entry_t 43 54 : #define MAP_PREV map.prev 44 108 : #define MAP_NEXT map.next 45 : #define MAP_OPTIMIZE_RANDOM_ACCESS_REMOVAL 1 46 : #include "../../../util/tmpl/fd_map_chain.c" 47 : 48 : typedef void 49 : (* fd_slot_delta_parser_process_group_fn_t)( void * _ctx, 50 : uchar const * blockhash, 51 : ulong txnhash_offset ); 52 : 53 : typedef void 54 : (* fd_slot_delta_parser_process_entry_fn_t)( void * _ctx, 55 : fd_sstxncache_entry_t const * entry ); 56 : 57 : FD_PROTOTYPES_BEGIN 58 : 59 : FD_FN_CONST ulong 60 : fd_slot_delta_parser_align( void ); 61 : 62 : FD_FN_CONST ulong 63 : fd_slot_delta_parser_footprint( void ); 64 : 65 : void * 66 : fd_slot_delta_parser_new( void * shmem ); 67 : 68 : fd_slot_delta_parser_t * 69 : fd_slot_delta_parser_join( void * shmem ); 70 : 71 : void * 72 : fd_slot_delta_parser_leave( fd_slot_delta_parser_t * parser ); 73 : 74 : void * 75 : fd_slot_delta_parser_delete( void * shmem ); 76 : 77 : void 78 : fd_slot_delta_parser_init( fd_slot_delta_parser_t * parser ); 79 : 80 : /* VerifySlotDeltasError::SlotIsNotRoot 81 : https://github.com/anza-xyz/agave/blob/v3.1.8/snapshots/src/error.rs#L135 */ 82 6 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ERROR_SLOT_IS_NOT_ROOT (-1) 83 : /* VerifySlotDeltasError:SlotHasMultipleEntries 84 : https://github.com/anza-xyz/agave/blob/v3.1.8/snapshots/src/error.rs#L141 */ 85 6 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ERROR_SLOT_HASH_MULTIPLE_ENTRIES (-2) 86 : /* VerifySlotDeltasError::TooManyEntries 87 : https://github.com/anza-xyz/agave/blob/v3.1.8/snapshots/src/error.rs#L132 */ 88 6 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ERROR_TOO_MANY_ENTRIES (-3) 89 0 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ERROR_EXCESS_DATA_IN_BUFFER (-4) 90 0 : #define FD_SLOT_DELTA_PARSER_ADVANCE_AGAIN ( 0) 91 108 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ENTRY ( 1) 92 57 : #define FD_SLOT_DELTA_PARSER_ADVANCE_GROUP ( 2) 93 78 : #define FD_SLOT_DELTA_PARSER_ADVANCE_DONE ( 3) 94 : 95 : struct fd_slot_delta_parser_advance_result { 96 : ulong bytes_consumed; 97 : union { 98 : fd_sstxncache_entry_t const * entry; 99 : 100 : struct { 101 : uchar const * blockhash; 102 : ulong txnhash_offset; 103 : } group; 104 : }; 105 : }; 106 : 107 : typedef struct fd_slot_delta_parser_advance_result fd_slot_delta_parser_advance_result_t; 108 : 109 : int 110 : fd_slot_delta_parser_consume( fd_slot_delta_parser_t * parser, 111 : uchar const * buf, 112 : ulong bufsz, 113 : fd_slot_delta_parser_advance_result_t * result ); 114 : 115 : /* fd_slot_delta_slot_set is a hash set of slots from the txncache. */ 116 : struct fd_slot_delta_slot_set { 117 : slot_set_t * map; 118 : fd_slot_entry_t * pool; 119 : ulong ele_cnt; /* number of slots */ 120 : }; 121 : typedef struct fd_slot_delta_slot_set fd_slot_delta_slot_set_t; 122 : 123 : fd_slot_delta_slot_set_t 124 : fd_slot_delta_parser_slot_set( fd_slot_delta_parser_t * parser ); 125 : 126 : FD_PROTOTYPES_END 127 : 128 : #endif /* HEADER_fd_src_discof_restore_utils_fd_slot_delta_parser_h */