LCOV - code coverage report
Current view: top level - disco/gui - fd_gui_shred.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 8 0.0 %
Date: 2026-10-22 18:10:43 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_disco_gui_fd_gui_shred_h
       2             : #define HEADER_fd_src_disco_gui_fd_gui_shred_h
       3             : 
       4             : #include "fd_gui_hist.h"
       5             : 
       6             : struct fd_gui;
       7             : typedef struct fd_gui fd_gui_t;
       8             : 
       9             : #define FD_GUI_SHRED_BATCH_SZ       (4096UL)
      10           0 : #define FD_GUI_SHRED_EVENT_TS_MAX   (0xFFFFFFUL)
      11             : 
      12           0 : #define FD_GUI_SLOT_SHRED_REPAIR_REQUEST         (0UL)
      13           0 : #define FD_GUI_SLOT_SHRED_SHRED_RECEIVED_TURBINE (1UL)
      14           0 : #define FD_GUI_SLOT_SHRED_SHRED_RECEIVED_REPAIR  (2UL)
      15           0 : #define FD_GUI_SLOT_SHRED_SHRED_REPLAY_EXEC_DONE (3UL)
      16           0 : #define FD_GUI_SLOT_SHRED_SHRED_SLOT_COMPLETE    (4UL)
      17           0 : #define FD_GUI_SLOT_SHRED_SHRED_PUBLISHED        (6UL)
      18             : 
      19             : struct __attribute__((packed)) fd_gui_shred_event {
      20             :   long   insert_time_ns;
      21             :   long   event_time_ns;
      22             :   uint   slot;
      23             :   ushort idx;
      24             :   uchar  event;
      25             : };
      26             : typedef struct fd_gui_shred_event fd_gui_shred_event_t;
      27             : 
      28             : struct fd_gui_shred_scratch {
      29             :   long   event_time_ns;
      30             :   uint   slot;
      31             :   ushort idx;
      32             :   uchar  event;
      33             : };
      34             : typedef struct fd_gui_shred_scratch fd_gui_shred_scratch_t;
      35             : 
      36           0 : #define FD_GUI_SHRED_SCRATCH_MAX (262144UL)
      37             : 
      38             : /* Each block belongs to one insertion-time second.  The index timestamp
      39             :    is that second's start; individual insertion times remain in data.
      40             :    Entries are a one-byte tag followed by either a literal event or a
      41             :    delta from the preceding event (same slot).  Deltas store the event
      42             :    type and delta signs in the tag, then four insertion-time bytes, three
      43             :    event-time bytes, and one index byte.  Slot changes and larger deltas
      44             :    use literals. */
      45             : struct fd_gui_shred_batch {
      46             :   long   insert_time_ns;
      47             :   uint   event_cnt;
      48             :   uint   data_sz;
      49             :   uchar  data[ FD_GUI_SHRED_BATCH_SZ-16UL ];
      50             : };
      51             : typedef struct fd_gui_shred_batch fd_gui_shred_batch_t;
      52             : 
      53             : /* Encode the open insertion second directly.  Full batches and closed
      54             :    seconds move to the history ring.  History retention only applies to
      55             :    sealed batches in the store; the active batch remains queryable. */
      56             : struct fd_gui_shred_builder {
      57             :   fd_gui_shred_batch_t batch;
      58             :   fd_gui_shred_event_t prev;
      59             : };
      60             : typedef struct fd_gui_shred_builder fd_gui_shred_builder_t;
      61             : 
      62             : struct fd_gui_shred_event_iter {
      63             :   fd_gui_shred_event_t event;
      64             :   fd_gui_t * _gui;
      65             :   long _after_ns;
      66             :   long _before_ns;
      67             :   fd_gui_hist_iter_t _hist_iter;
      68             :   fd_gui_shred_batch_t const * _batch;
      69             :   ulong _batch_idx;
      70             :   ulong _data_off;
      71             :   int   _event_time;
      72             :   int   _builder_pending;
      73             :   int   _hist_active;
      74             : };
      75             : typedef struct fd_gui_shred_event_iter fd_gui_shred_event_iter_t;
      76             : 
      77             : FD_PROTOTYPES_BEGIN
      78             : 
      79             : /* Iterate by original insertion time, inclusive at both ends.  Event
      80             :    timestamps are preserved verbatim and need not be ordered. */
      81             : fd_gui_shred_event_iter_t *
      82             : fd_gui_shred_event_iter_begin( fd_gui_t *                  gui,
      83             :                                fd_gui_shred_event_iter_t * iter,
      84             :                                long                        after_ns,
      85             :                                long                        before_ns );
      86             : 
      87             : /* fd_gui_shred_event_hist_iter_begin selects event time in
      88             :    [after_ns,before_ns).  Event times are only approximately ordered
      89             :    with insertion, so the scan is widened by one second on each side. */
      90             : fd_gui_shred_event_iter_t *
      91             : fd_gui_shred_event_hist_iter_begin( fd_gui_t *                  gui,
      92             :                                     fd_gui_shred_event_iter_t * iter,
      93             :                                     long                        after_ns,
      94             :                                     long                        before_ns );
      95             : 
      96             : int
      97             : fd_gui_shred_event_iter_next( fd_gui_shred_event_iter_t * iter );
      98             : 
      99             : void
     100             : fd_gui_shred_event_iter_end( fd_gui_shred_event_iter_t * iter );
     101             : 
     102             : /* Append immediately.  now is the GUI insertion time and must be
     103             :    nondecreasing across all channels; timestamp is the source event time. */
     104             : void
     105             : fd_gui_shred_event_append( fd_gui_t * gui,
     106             :                            ulong      slot,
     107             :                            ulong      idx,
     108             :                            uchar      event,
     109             :                            long       timestamp,
     110             :                            long       now );
     111             : 
     112             : /* Seal the active batch once its insertion second has closed.
     113             :    Returns 1 when a batch was flushed. */
     114             : int
     115             : fd_gui_shred_flush( fd_gui_t * gui,
     116             :                     long       now );
     117             : 
     118             : int
     119             : fd_gui_shred_window_is_empty( fd_gui_t * gui,
     120             :                               long       after_ns,
     121             :                               long       before_ns );
     122             : 
     123             : /* fd_gui_event_bounds returns whether dbi has lookup bounds, writing
     124             :    half-open [lo,hi) bounds that include the active shred batch. */
     125             : 
     126             : int
     127             : fd_gui_event_bounds( fd_gui_t * gui,
     128             :                      int        dbi,
     129             :                      long *     lo,
     130             :                      long *     hi );
     131             : 
     132             : FD_PROTOTYPES_END
     133             : 
     134             : #endif /* HEADER_fd_src_disco_gui_fd_gui_shred_h */

Generated by: LCOV version 1.14