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 "../../ballet/json/cJSON.h" 5 : #include "../../flamenco/types/fd_types_custom.h" 6 : #include "../../util/fd_util_base.h" 7 : 8 : /* https://github.com/anza-xyz/agave/blob/master/account-decoder/src/validator_info.rs */ 9 0 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_NAME_SZ ( 80UL) /* +1UL for NULL terminator */ 10 0 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_WEBSITE_SZ ( 80UL) 11 0 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_DETAILS_SZ ( 300UL) 12 0 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_ICON_URI_SZ ( 80UL) 13 0 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_KEYBASE_USERNAME_SZ ( 80UL) 14 0 : #define FD_GUI_CONFIG_PARSE_VALIDATOR_INFO_MAX_SZ ( 576UL) /* does not include size of ConfigKeys */ 15 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) 16 0 : #define FD_GUI_CONFIG_PARSE_MAX_VALID_ACCT_SZ_WITH_NULL (FD_GUI_CONFIG_PARSE_MAX_VALID_ACCT_SZ+1UL) /* cJSON parser requires one byte past the parsable JSON */ 17 : 18 : /* The size of a ConfigKeys of length 2, which is the expected length of ValidatorInfo */ 19 0 : #define FD_GUI_CONFIG_PARSE_CONFIG_KEYS_MAX_SZ (1UL + (32UL + 1UL)*2UL) 20 : 21 : struct fd_gui_config_parse_info { 22 : fd_pubkey_t pubkey; 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 : int 38 : fd_gui_config_parse_validator_info_check( uchar const * data, 39 : ulong sz, 40 : cJSON ** out_json, 41 : fd_pubkey_t * out_pubkey ); 42 : 43 : void 44 : fd_gui_config_parse_validator_info( cJSON * json, fd_gui_config_parse_info_t * node_info ); 45 : 46 : FD_PROTOTYPES_END 47 : 48 : #endif /* HEADER_fd_src_disco_gui_fd_gui_config_parse_h */