Line data Source code
1 : #ifndef HEADER_fd_src_disco_gui_fd_gui_config_parse_h 2 : #define HEADER_fd_src_disco_gui_fd_gui_config_parse_h 3 : 4 : #include "../../flamenco/fd_flamenco_base.h" 5 : 6 : /* https://github.com/anza-xyz/agave/blob/master/account-decoder/src/validator_info.rs */ 7 0 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_NAME_SZ ( 80UL) /* +1UL for NULL terminator */ 8 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_WEBSITE_SZ ( 80UL) 9 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_DETAILS_SZ ( 300UL) 10 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_ICON_URI_SZ ( 80UL) 11 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_KEYBASE_USERNAME_SZ ( 80UL) 12 0 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_MAX_SZ ( 576UL) /* does not include size of ConfigKeys */ 13 0 : #define FD_GUI_CONFIG_PARSE_MAX_VALID_ACCT_SZ (FD_GUI_CONFIG_PARSE_CONFIG_KEYS_MAX_SZ+FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_MAX_SZ) 14 : 15 : /* The size of a ConfigKeys of length 2, which is the expected length of ValidatorInfo */ 16 0 : #define FD_GUI_CONFIG_PARSE_CONFIG_KEYS_MAX_SZ (1UL + (32UL + 1UL)*2UL) 17 : 18 : struct fd_gui_config_parse_info { 19 : fd_pubkey_t pubkey; 20 : ulong slot; 21 : int cleared; 22 : 23 : char name [ FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_NAME_SZ + 1UL ]; /* +1UL for NULL */ 24 : char website [ FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_WEBSITE_SZ + 1UL ]; 25 : char details [ FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_DETAILS_SZ + 1UL ]; 26 : char icon_uri[ FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_ICON_URI_SZ + 1UL ]; 27 : char keybase_username[ FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_KEYBASE_USERNAME_SZ + 1UL ]; 28 : 29 : struct { ulong prev, next; } map; 30 : struct { ulong next; } pool; 31 : }; 32 : 33 : typedef struct fd_gui_config_parse_info fd_gui_config_parse_info_t; 34 : 35 : FD_PROTOTYPES_BEGIN 36 : 37 : /* fd_gui_config_parse_validator_info parses the sz bytes at data as a 38 : ConfigProgram account holding a ValidatorInfo. Returns 1 on success 39 : with info->pubkey and the string fields populated (a field that is 40 : absent, not a string, or longer than its max is set to the empty 41 : string). Returns 0 if the account is not a ValidatorInfo or the 42 : JSON is malformed. */ 43 : 44 : int 45 : fd_gui_config_parse_validator_info( uchar const * data, 46 : ulong sz, 47 : fd_gui_config_parse_info_t * info ); 48 : 49 : FD_PROTOTYPES_END 50 : 51 : #endif /* HEADER_fd_src_disco_gui_fd_gui_config_parse_h */