Line data Source code
1 : #ifndef HEADER_fd_src_discof_repair_fd_inflight_h 2 : #define HEADER_fd_src_discof_repair_fd_inflight_h 3 : 4 : #include "../../flamenco/types/fd_types.h" 5 : 6 : /* fd_inflights tracks repair requests that are inflight to other 7 : validators. This module is not necessary for the repair protocol and 8 : strategy, but is useful for metrics and reporting. Incorrect updates 9 : and removals from this module are non-critical. Requests are key-ed 10 : by nonce as in the current strategy (see fd_policy.h), all requests 11 : have a unique nonce. The chances that an inflight request does not 12 : get a response are non-negligible due to shred tile upstream deduping 13 : duplicates. */ 14 : 15 : /* Max number of pending requests */ 16 0 : #define FD_INFLIGHT_REQ_MAX (1<<20) 17 : 18 : struct __attribute__((aligned(128UL))) fd_inflight { 19 : ulong nonce; /* unique identifier for the request */ 20 : ulong next; /* reserved for internal use by fd_pool and fd_map_chain */ 21 : long timestamp_ns; /* timestamp when request was created (nanoseconds) */ 22 : fd_pubkey_t pubkey; /* public key of the peer */ 23 : 24 : /* Reserved for DLL eviction */ 25 : ulong prevll; /* pool index of previous element in DLL */ 26 : ulong nextll; /* pool index of next element in DLL */ 27 : }; 28 : typedef struct fd_inflight fd_inflight_t; 29 : 30 : #define POOL_NAME fd_inflight_pool 31 0 : #define POOL_T fd_inflight_t 32 : #include "../../util/tmpl/fd_pool.c" 33 : 34 : #define MAP_NAME fd_inflight_map 35 0 : #define MAP_KEY nonce 36 : #define MAP_ELE_T fd_inflight_t 37 : #include "../../util/tmpl/fd_map_chain.c" 38 : 39 : #define DLIST_NAME fd_inflight_dlist 40 : #define DLIST_ELE_T fd_inflight_t 41 0 : #define DLIST_PREV prevll 42 0 : #define DLIST_NEXT nextll 43 : #include "../../util/tmpl/fd_dlist.c" 44 : 45 : struct fd_inflights { 46 : fd_inflight_t * pool; 47 : fd_inflight_map_t * map; 48 : fd_inflight_dlist_t * dlist; 49 : }; 50 : typedef struct fd_inflights fd_inflights_t; 51 : 52 : FD_FN_CONST static inline ulong 53 0 : fd_inflights_align( void ) { return 128UL; } 54 : 55 : FD_FN_CONST static inline ulong 56 0 : fd_inflights_footprint( void ) { 57 0 : return FD_LAYOUT_FINI( 58 0 : FD_LAYOUT_APPEND( 59 0 : FD_LAYOUT_APPEND( 60 0 : FD_LAYOUT_APPEND( 61 0 : FD_LAYOUT_APPEND( 62 0 : FD_LAYOUT_INIT, 63 0 : alignof(fd_inflights_t), sizeof(fd_inflights_t) ), 64 0 : fd_inflight_pool_align(), fd_inflight_pool_footprint ( FD_INFLIGHT_REQ_MAX ) ), 65 0 : fd_inflight_map_align(), fd_inflight_map_footprint ( FD_INFLIGHT_REQ_MAX ) ), 66 0 : fd_inflight_dlist_align(), fd_inflight_dlist_footprint() ), 67 0 : fd_inflights_align() ); 68 0 : } 69 : 70 : void * 71 : fd_inflights_new( void * shmem ); 72 : 73 : fd_inflights_t * 74 : fd_inflights_join( void * shmem ); 75 : 76 : void 77 : fd_inflights_request_insert( fd_inflights_t * table, ulong nonce, fd_pubkey_t const * pubkey ); 78 : 79 : long 80 : fd_inflights_request_remove( fd_inflights_t * table, ulong nonce, fd_pubkey_t * peer_out ); 81 : 82 : fd_inflight_t * 83 : fd_inflights_request_query ( fd_inflights_t * table, ulong nonce ); 84 : 85 : #endif /* HEADER_fd_src_discof_repair_fd_inflight_h */