Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_capture_fd_solcap_writer_h 2 : #define HEADER_fd_src_flamenco_capture_fd_solcap_writer_h 3 : 4 : #include "fd_solcap_proto.h" 5 : 6 : /* fd_solcap_writer_t produces pcapng dumps containing solcap packets. 7 : 8 : Each solcap write function is responsible for encoding and writing 9 : out a specific type of chunk. They provide both a header, which 10 : contains information about type of chunk, size, and slot number, 11 : and the chunk data. 12 : 13 : Note: The functionality is limited to the writing of solcap v2 files 14 : Nishk (TODO): Write docs for solcap writer 15 : */ 16 : 17 : FD_PROTOTYPES_BEGIN 18 : 19 : /* Maximum fragment size for account data. Must be <= USHORT_MAX (65535) 20 : because fd_frag_meta_t stores sz as a ushort. */ 21 0 : #define SOLCAP_WRITE_ACCOUNT_DATA_MTU (65535UL) 22 : 23 : struct fd_solcap_writer { 24 : int fd; 25 : }; 26 : typedef struct fd_solcap_writer fd_solcap_writer_t; 27 : 28 : ulong 29 : fd_solcap_writer_align( void ); 30 : 31 : ulong 32 : fd_solcap_writer_footprint( void ); 33 : 34 : fd_solcap_writer_t * 35 : fd_solcap_writer_init( fd_solcap_writer_t * writer, 36 : int fd ); 37 : 38 : /* fd_solcap_write_account_hdr writes an account update EPB header. 39 : Writes EPB + internal chunk header + account metadata. Account data 40 : must be written separately via fd_solcap_write_data. Returns the 41 : total block_len for use when writing the footer. */ 42 : 43 : uint 44 : fd_solcap_write_account_hdr( fd_solcap_writer_t * writer, 45 : fd_solcap_buf_msg_t * msg_hdr, 46 : fd_solcap_account_update_hdr_t * account_update ); 47 : 48 : /* fd_solcap_write_data writes raw data bytes to the capture file. 49 : This is used for continuation fragments of any message type that 50 : spans multiple link fragments (e.g., large account data). */ 51 : uint 52 : fd_solcap_write_data( fd_solcap_writer_t * writer, 53 : void const * data, 54 : ulong data_sz ); 55 : 56 : /* fd_solcap_write_bank_preimage writes a complete bank preimage EPB. 57 : Contains bank hash, prev hash, accounts hash, PoH hash, and sig count. 58 : Returns block_len for the footer. */ 59 : 60 : uint 61 : fd_solcap_write_bank_preimage( fd_solcap_writer_t * writer, 62 : fd_solcap_buf_msg_t * msg_hdr, 63 : fd_solcap_bank_preimage_t * bank_preimage ); 64 : 65 : /* fd_solcap_write_stake_rewards_begin writes a stake rewards begin EPB. 66 : Marks the start of epoch rewards distribution with inflation and 67 : point totals. Returns block_len for the footer. */ 68 : 69 : uint 70 : fd_solcap_write_stake_rewards_begin( fd_solcap_writer_t * writer, 71 : fd_solcap_buf_msg_t * msg_hdr, 72 : fd_solcap_stake_rewards_begin_t * stake_rewards_begin ); 73 : 74 : /* fd_solcap_write_stake_reward_event writes a stake reward event EPB. 75 : Captures individual reward calculation for a stake/vote account pair. 76 : Returns block_len for the footer. */ 77 : 78 : uint 79 : fd_solcap_write_stake_reward_event( fd_solcap_writer_t * writer, 80 : fd_solcap_buf_msg_t * msg_hdr, 81 : fd_solcap_stake_reward_event_t * stake_reward_event ); 82 : 83 : /* fd_solcap_write_stake_account_payout writes a stake payout EPB. 84 : Captures stake account state changes during reward distribution. 85 : Returns block_len for the footer. */ 86 : 87 : uint 88 : fd_solcap_write_stake_account_payout( fd_solcap_writer_t * writer, 89 : fd_solcap_buf_msg_t * msg_hdr, 90 : fd_solcap_stake_account_payout_t * stake_account_payout ); 91 : 92 : /* fd_solcap_write_ftr writes the PCapNG block footer. Adds padding to 93 : align to 4-byte boundary, then writes the redundant block length. 94 : Must be called after each message to complete the EPB. */ 95 : 96 : uint 97 : fd_solcap_write_ftr( fd_solcap_writer_t * writer, 98 : uint block_len_redundant ); 99 : 100 : FD_PROTOTYPES_END 101 : 102 : #endif /* HEADER_fd_src_flamenco_capture_fd_solcap_writer_h */