LCOV - code coverage report
Current view: top level - discof/backtest - fd_backtest_src.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 17 0.0 %
Date: 2026-08-13 04:56:22 Functions: 0 28 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_backtest_fd_backtest_src_h
       2             : #define HEADER_fd_src_discof_backtest_fd_backtest_src_h
       3             : 
       4             : #include "../../flamenco/fd_flamenco_base.h"
       5             : 
       6             : /* Ledger source format IDs, shared between the format auto-detector
       7             :    (fd_backtest_src.c) and the pcap reader (fd_backtest_src_pcap.c). */
       8             : 
       9           0 : #define FD_BACKT_SRC_INVAL       0x00u
      10           0 : #define FD_BACKT_SRC_FMT_PCAP    0x02u
      11           0 : #define FD_BACKT_SRC_FMT_PCAPNG  0x03u
      12           0 : #define FD_BACKT_SRC_FMT_MASK    0x07u
      13           0 : #define FD_BACKT_SRC_FLAG_ZSTD   0x08u
      14             : 
      15             : struct fd_backt_slot_info {
      16             :   ulong     slot;
      17             :   fd_hash_t bank_hash;
      18             :   uint      bank_hash_set : 1;
      19             :   uint      optimistic_confirmed : 1;
      20             :   uint      rooted : 1;
      21             :   uint      dead : 1;
      22             : };
      23             : typedef struct fd_backt_slot_info fd_backt_slot_info_t;
      24             : 
      25             : typedef struct fd_backt_src_vt fd_backt_src_vt_t;
      26             : 
      27             : struct fd_backt_src {
      28             :   fd_backt_src_vt_t const * vt;
      29             : };
      30             : typedef struct fd_backt_src fd_backt_src_t;
      31             : 
      32             : struct fd_backt_src_vt {
      33             : 
      34             :   void
      35             :   (* destroy)( fd_backt_src_t * this );
      36             : 
      37             :   ulong
      38             :   (* first_shred)( fd_backt_src_t * this,
      39             :                    uchar  *         buf,
      40             :                    ulong            buf_sz );
      41             : 
      42             :   ulong
      43             :   (* shred)( fd_backt_src_t * this,
      44             :              uchar  *         buf,
      45             :              ulong            buf_sz );
      46             : 
      47             :   fd_backt_slot_info_t *
      48             :   (* slot_info)( fd_backt_src_t *       this,
      49             :                  fd_backt_slot_info_t * out,
      50             :                  ulong                  slot );
      51             : 
      52             :   void
      53             :   (* seek)( fd_backt_src_t * this,
      54             :             ulong            slot );
      55             : 
      56             : };
      57             : 
      58             : struct fd_backtest_src_opts {
      59             :   char const * format;
      60             :   char const * path;
      61             : 
      62             :   uint rooted_only : 1;
      63             :   uint code_shreds : 1;
      64             : };
      65             : typedef struct fd_backtest_src_opts fd_backtest_src_opts_t;
      66             : 
      67             : FD_PROTOTYPES_BEGIN
      68             : 
      69             : /* fd_backtest_src_first_shred peeks the first shred of the source.
      70             :    Returns the size of the shred (non-zero) on success or zero on
      71             :    failure (logs warning).  Writes the shred payload to buf. */
      72             : 
      73             : ulong
      74             : fd_backtest_src_first_shred( fd_backtest_src_opts_t const * opts,
      75             :                              uchar *                        buf,
      76             :                              ulong                          buf_sz );
      77             : 
      78             : /* fd_backtest_src_create constructs a ledger shred source with the
      79             :    given options.  Returns a newly allocated backtest_src object on
      80             :    success, or NULL on failure (logs warning). */
      81             : 
      82             : fd_backt_src_t *
      83             : fd_backtest_src_create( fd_backtest_src_opts_t const * opts );
      84             : 
      85             : /* fd_backtest_src_destroy frees backtest_src and all its resources. */
      86             : 
      87             : static inline void
      88           0 : fd_backtest_src_destroy( fd_backt_src_t * db ) {
      89           0 :   db->vt->destroy( db );
      90           0 : }
      91             : 
      92             : /* fd_backtest_src_shred consumes the backtest_src's next shred. */
      93             : 
      94             : static inline ulong
      95             : fd_backtest_src_shred( fd_backt_src_t * db,
      96             :                        uchar *          buf,
      97           0 :                        ulong            buf_sz ) {
      98           0 :   return db->vt->shred( db, buf, buf_sz );
      99           0 : }
     100             : 
     101             : /* fd_backtest_src_slot_info queries consensus info for the given slot. */
     102             : 
     103             : static inline fd_backt_slot_info_t *
     104             : fd_backtest_src_slot_info( fd_backt_src_t *       db,
     105             :                            fd_backt_slot_info_t * out,
     106           0 :                            ulong                  slot ) {
     107           0 :   return db->vt->slot_info( db, out, slot );
     108           0 : }
     109             : 
     110             : /* fd_backtest_src_seek advances the source so that the next shred
     111             :    returned by fd_backtest_src_shred has slot>=slot. */
     112             : 
     113             : static inline void
     114             : fd_backtest_src_seek( fd_backt_src_t * db,
     115           0 :                       ulong            slot ) {
     116           0 :   if( db->vt->seek ) db->vt->seek( db, slot );
     117           0 : }
     118             : 
     119             : FD_PROTOTYPES_END
     120             : 
     121             : #endif /* HEADER_fd_src_discof_backtest_fd_backtest_src_h */

Generated by: LCOV version 1.14