Line data Source code
1 : #ifndef HEADER_fd_src_discof_backup_fd_ssmanifest_writer_h 2 : #define HEADER_fd_src_discof_backup_fd_ssmanifest_writer_h 3 : 4 : /* fd_ssmanifest_writer.h provides streaming serialization of a Solana 5 : snapshot manifest. */ 6 : 7 : #include "../../flamenco/runtime/fd_bank.h" 8 : 9 : struct fd_ssmanifest_writer { 10 : uint state; 11 : fd_bank_t * bank; 12 : uchar epoch_idx; 13 : uchar epoch_cnt; 14 : uint vote_cnt; 15 : uint vote_idx; 16 : ulong total_stake; 17 : uchar vote_stakes_iter_mem[ FD_VOTE_STAKES_T_2_ITER_FOOTPRINT ] __attribute__((aligned(FD_VOTE_STAKES_T_2_ITER_ALIGN))); 18 : }; 19 : 20 : typedef struct fd_ssmanifest_writer fd_ssmanifest_writer_t; 21 : 22 : FD_PROTOTYPES_BEGIN 23 : 24 : /* fd_ssmanifest_writer_init creates a new snapshot manifest writer. 25 : Guaranteed to succeed for a valid bank. */ 26 : 27 : fd_ssmanifest_writer_t * 28 : fd_ssmanifest_writer_init( fd_ssmanifest_writer_t * writer, 29 : fd_bank_t * bank ); 30 : 31 : /* fd_snap_manifest_serialize serializes up to buf_sz worth of snapshot 32 : manifest data into out_buf. Returns the number of bytes written. 33 : Returns 0UL if the manifest was fully serialized out. Typical usage: 34 : 35 : uchar out_buf[ FD_SSMANIFEST_BUF_MIN ]; 36 : for(;;) { 37 : ulong sz = fd_snap_manifest_serialize( enc, out_buf, sizeof(out_buf) ); 38 : if( !sz ) break; 39 : fd_io_write( ... ); // write out chunk 40 : } 41 : 42 : Produces 1 GiB-ish data for a mainnet snapshot. */ 43 : 44 108 : #define FD_SSMANIFEST_BUF_MIN (32UL<<20) 45 : ulong 46 : fd_snap_manifest_serialize( fd_ssmanifest_writer_t * enc, 47 : uchar out_buf[ FD_SSMANIFEST_BUF_MIN ], 48 : ulong buf_sz ); 49 : 50 : /* fd_snapshot_manifest_serialized_sz returns the total amount of data 51 : that fd_snap_manifest_serialize would produce for the given bank. */ 52 : 53 : ulong 54 : fd_snap_manifest_serialized_sz( fd_bank_t * bank ); 55 : 56 : FD_PROTOTYPES_END 57 : 58 : #endif /* HEADER_fd_src_discof_backup_fd_ssmanifest_writer_h */