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 6 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ERROR_SLOT_IS_NOT_ROOT (-1) 81 6 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ERROR_SLOT_HASH_MULTIPLE_ENTRIES (-2) 82 6 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ERROR_TOO_MANY_ENTRIES (-3) 83 0 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ERROR_EXCESS_DATA_IN_BUFFER (-4) 84 0 : #define FD_SLOT_DELTA_PARSER_ADVANCE_AGAIN ( 0) 85 108 : #define FD_SLOT_DELTA_PARSER_ADVANCE_ENTRY ( 1) 86 57 : #define FD_SLOT_DELTA_PARSER_ADVANCE_GROUP ( 2) 87 78 : #define FD_SLOT_DELTA_PARSER_ADVANCE_DONE ( 3) 88 : 89 : struct fd_slot_delta_parser_advance_result { 90 : ulong bytes_consumed; 91 : union { 92 : fd_sstxncache_entry_t const * entry; 93 : 94 : struct { 95 : uchar const * blockhash; 96 : ulong txnhash_offset; 97 : } group; 98 : }; 99 : }; 100 : 101 : typedef struct fd_slot_delta_parser_advance_result fd_slot_delta_parser_advance_result_t; 102 : 103 : int 104 : fd_slot_delta_parser_consume( fd_slot_delta_parser_t * parser, 105 : uchar const * buf, 106 : ulong bufsz, 107 : fd_slot_delta_parser_advance_result_t * result ); 108 : 109 : FD_PROTOTYPES_END 110 : 111 : #endif /* HEADER_fd_src_discof_restore_utils_fd_slot_delta_parser_h */