LCOV - code coverage report
Current view: top level - discof/backtest - fd_backtest_src.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 12 0.0 %
Date: 2026-06-29 05:51:35 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             : struct fd_backt_slot_info {
       7             :   ulong     slot;
       8             :   fd_hash_t bank_hash;
       9             :   uint      bank_hash_set : 1;
      10             :   uint      optimistic_confirmed : 1;
      11             :   uint      rooted : 1;
      12             :   uint      dead : 1;
      13             : };
      14             : typedef struct fd_backt_slot_info fd_backt_slot_info_t;
      15             : 
      16             : typedef struct fd_backt_src_vt fd_backt_src_vt_t;
      17             : 
      18             : struct fd_backt_src {
      19             :   fd_backt_src_vt_t const * vt;
      20             : };
      21             : typedef struct fd_backt_src fd_backt_src_t;
      22             : 
      23             : struct fd_backt_src_vt {
      24             : 
      25             :   void
      26             :   (* destroy)( fd_backt_src_t * this );
      27             : 
      28             :   ulong
      29             :   (* first_shred)( fd_backt_src_t * this,
      30             :                    uchar  *         buf,
      31             :                    ulong            buf_sz );
      32             : 
      33             :   ulong
      34             :   (* shred)( fd_backt_src_t * this,
      35             :              uchar  *         buf,
      36             :              ulong            buf_sz );
      37             : 
      38             :   fd_backt_slot_info_t *
      39             :   (* slot_info)( fd_backt_src_t *       this,
      40             :                  fd_backt_slot_info_t * out,
      41             :                  ulong                  slot );
      42             : 
      43             :   void
      44             :   (* seek)( fd_backt_src_t * this,
      45             :             ulong            slot );
      46             : 
      47             : };
      48             : 
      49             : struct fd_backtest_src_opts {
      50             :   char const * format;
      51             :   char const * path;
      52             : 
      53             :   uint rooted_only : 1;
      54             :   uint code_shreds : 1;
      55             : };
      56             : typedef struct fd_backtest_src_opts fd_backtest_src_opts_t;
      57             : 
      58             : FD_PROTOTYPES_BEGIN
      59             : 
      60             : /* fd_backtest_src_first_shred peeks the first shred of the source.
      61             :    Returns the size of the shred (non-zero) on success or zero on
      62             :    failure (logs warning).  Writes the shred payload to buf. */
      63             : 
      64             : ulong
      65             : fd_backtest_src_first_shred( fd_backtest_src_opts_t const * opts,
      66             :                              uchar *                        buf,
      67             :                              ulong                          buf_sz );
      68             : 
      69             : /* fd_backtest_src_create constructs a ledger shred source with the
      70             :    given options.  Returns a newly allocated backtest_src object on
      71             :    success, or NULL on failure (logs warning). */
      72             : 
      73             : fd_backt_src_t *
      74             : fd_backtest_src_create( fd_backtest_src_opts_t const * opts );
      75             : 
      76             : /* fd_backtest_src_destroy frees backtest_src and all its resources. */
      77             : 
      78             : static inline void
      79           0 : fd_backtest_src_destroy( fd_backt_src_t * db ) {
      80           0 :   db->vt->destroy( db );
      81           0 : }
      82             : 
      83             : /* fd_backtest_src_shred consumes the backtest_src's next shred. */
      84             : 
      85             : static inline ulong
      86             : fd_backtest_src_shred( fd_backt_src_t * db,
      87             :                        uchar *          buf,
      88           0 :                        ulong            buf_sz ) {
      89           0 :   return db->vt->shred( db, buf, buf_sz );
      90           0 : }
      91             : 
      92             : /* fd_backtest_src_slot_info queries consensus info for the given slot. */
      93             : 
      94             : static inline fd_backt_slot_info_t *
      95             : fd_backtest_src_slot_info( fd_backt_src_t *       db,
      96             :                            fd_backt_slot_info_t * out,
      97           0 :                            ulong                  slot ) {
      98           0 :   return db->vt->slot_info( db, out, slot );
      99           0 : }
     100             : 
     101             : /* fd_backtest_src_seek advances the source so that the next shred
     102             :    returned by fd_backtest_src_shred has slot>=slot. */
     103             : 
     104             : static inline void
     105             : fd_backtest_src_seek( fd_backt_src_t * db,
     106           0 :                       ulong            slot ) {
     107           0 :   if( db->vt->seek ) db->vt->seek( db, slot );
     108           0 : }
     109             : 
     110             : FD_PROTOTYPES_END
     111             : 
     112             : #endif /* HEADER_fd_src_discof_backtest_fd_backtest_src_h */

Generated by: LCOV version 1.14