LCOV - code coverage report
Current view: top level - discof/restore/utils - fd_ssparse.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 10 0.0 %
Date: 2026-08-14 04:54:57 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_restore_utils_fd_ssparse_h
       2             : #define HEADER_fd_src_discof_restore_utils_fd_ssparse_h
       3             : 
       4             : #include "../../../util/fd_util_base.h"
       5             : 
       6           0 : #define FD_SSPARSE_ADVANCE_ERROR          (-1)
       7           0 : #define FD_SSPARSE_ADVANCE_AGAIN          ( 0)
       8           0 : #define FD_SSPARSE_ADVANCE_MANIFEST       ( 1)
       9           0 : #define FD_SSPARSE_ADVANCE_MANIFEST_DONE  ( 2)
      10           0 : #define FD_SSPARSE_ADVANCE_STATUS_CACHE   ( 3)
      11           0 : #define FD_SSPARSE_ADVANCE_ACCOUNT_HEADER ( 4)
      12           0 : #define FD_SSPARSE_ADVANCE_ACCOUNT_DATA   ( 5)
      13           0 : #define FD_SSPARSE_ADVANCE_ACCOUNT_BATCH  ( 6)
      14           0 : #define FD_SSPARSE_ADVANCE_DONE           ( 7)
      15             : 
      16             : /* fd_ssparse_t is a solana snapshot parser.  It is designed to parse a
      17             :    snapshot in streaming fashion, chunk by chunk. */
      18             : struct fd_ssparse {
      19             :   int state;
      20             :   uint batch_enabled : 1;
      21             : 
      22             :   struct {
      23             :     int seen_zero_tar_frame;
      24             :     int seen_manifest;
      25             :     int seen_status_cache;
      26             :     int seen_version;
      27             :   } flags;
      28             : 
      29             :   uchar version[ 5UL ];
      30             : 
      31             :   struct {
      32             :     uchar header[ 512UL ];
      33             :     ulong file_bytes;
      34             :     ulong file_bytes_consumed;
      35             :     ulong header_bytes_consumed;
      36             :   } tar;
      37             : 
      38             :   struct {
      39             :     uchar header[ 136UL ];
      40             :     ulong header_bytes_consumed;
      41             :     ulong data_bytes_consumed;
      42             :     ulong data_len;
      43             :   } account;
      44             : 
      45             :   ulong acc_vec_bytes;
      46             :   ulong slot;
      47             :   ulong bytes_consumed;
      48             : };
      49             : 
      50             : typedef struct fd_ssparse fd_ssparse_t;
      51             : 
      52             : /* FD_SSPARSE_ACC_BATCH_MAX controls the max number of accounts in a
      53             :    batch. */
      54           0 : #define FD_SSPARSE_ACC_BATCH_MAX (8UL)
      55             : 
      56             : struct fd_ssparse_advance_result {
      57             :   ulong bytes_consumed;
      58             : 
      59             :   union {
      60             :     struct {
      61             :       uchar const *   data;
      62             :       ulong           data_sz;
      63             :     } manifest;
      64             : 
      65             :     struct {
      66             :       uchar const * data;
      67             :       ulong         data_sz;
      68             :       int           done;
      69             :     } status_cache;
      70             : 
      71             :     struct {
      72             :       ulong         slot;
      73             :       ulong         data_len;
      74             :       uchar const * pubkey;
      75             :       ulong         lamports;
      76             :       ulong         rent_epoch;
      77             :       uchar const * owner;
      78             :       int           executable;
      79             :       uchar const * hash;
      80             :     } account_header;
      81             : 
      82             :     struct {
      83             :       uchar const * data;
      84             :       ulong         data_sz;
      85             :     } account_data;
      86             : 
      87             :     struct {
      88             :       /* Points to first byte of each account entry
      89             :          Each account entry is guaranteed unfragmented
      90             :          Useful for fast path processing */
      91             :       uchar const * batch[ FD_SSPARSE_ACC_BATCH_MAX ];
      92             :       ulong         batch_cnt;
      93             :       ulong         slot;
      94             :     } account_batch;
      95             :   };
      96             : };
      97             : 
      98             : typedef struct fd_ssparse_advance_result fd_ssparse_advance_result_t;
      99             : 
     100             : FD_PROTOTYPES_BEGIN
     101             : 
     102             : fd_ssparse_t *
     103             : fd_ssparse_init( fd_ssparse_t * ssparse );
     104             : 
     105             : /* fd_ssparse_advance parses a snapshot stream chunk.
     106             : 
     107             :    ssparse points to the parser.  data points to the snapshot stream.
     108             :    data_sz is the size of the snapshot stream chunk.  result points to
     109             :    fd_ssparse_advance_result_t object.  On success, the contents of the
     110             :    result are populated according to the return result.  result is not
     111             :    populated if the return result is ADVANCE_AGAIN or ADVANCE_ERROR. */
     112             : int
     113             : fd_ssparse_advance( fd_ssparse_t *                ssparse,
     114             :                     uchar const *                 data,
     115             :                     ulong                         data_sz,
     116             :                     fd_ssparse_advance_result_t * result );
     117             : 
     118             : /* fd_ssparse_batch_enable toggles whether batch processing is enabled.
     119             :    If enabled, ssparse will deliver FD_SSPARSE_ADVANCE_ACCOUNT_BATCH
     120             :    messages.  (These may help the caller processing accounts in batches
     121             :    to amortize per-account overhead, such as slow DRAM/disk fetches.) */
     122             : void
     123             : fd_ssparse_batch_enable( fd_ssparse_t * ssparse,
     124             :                          int            enabled );
     125             : 
     126             : FD_PROTOTYPES_END
     127             : 
     128             : #endif /* HEADER_fd_src_discof_restore_utils_fd_ssparse_h */

Generated by: LCOV version 1.14