LCOV - code coverage report
Current view: top level - discof/backup - fd_snapsv_tile.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 3 7 42.9 %
Date: 2026-09-17 04:28:31 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_backup_fd_snapsv_tile_h
       2             : #define HEADER_fd_src_discof_backup_fd_snapsv_tile_h
       3             : 
       4             : /* fd_snapsv_tile.h specifies the snapsv tile ABI.
       5             : 
       6             :    The snapsv tile is a HTTP/1.1 file server that serves local snapshots
       7             :    to remote peers. */
       8             : 
       9             : #include "../../util/net/fd_ip6.h"
      10             : 
      11             : /* The snapsv_out link replicates out snapshot server state to external
      12             :    consumers.  Currently, events for the following tables exist:
      13             : 
      14             :    - snapshot downloads: active snapshot download HTTP connections with
      15             :      periodic progress updates (SYNC_PERIOD)
      16             : 
      17             :    Notes on the sync protocol:
      18             : 
      19             :    - each frag fully describes a row revision
      20             :    - every SYNC_PERIOD, each row generates an update (all rows are
      21             :      published in one burst)
      22             :    - if SYNC_EXPIRY time passes without an update, consumers remove that
      23             :      row (to recover from dropped deletions)
      24             : 
      25             :    Generic frag_meta fields:
      26             :    - sig: FD_SNAPSV_MSG_*
      27             :    - tspub: unix nanosecond timestamp of event (**not tickcount**) */
      28             : 
      29           0 : #define FD_SNAPSV_WAKE_PERIOD ((long)50e6) /*   50 ms */
      30        1602 : #define FD_SNAPSV_SYNC_PERIOD ((long)50e6) /*   50 ms */
      31           0 : #define FD_SNAPSV_SYNC_EXPIRY ((long) 1e9) /* 1000 ms */
      32             : 
      33             : /* FD_SNAPSV_MSG_* give message types */
      34             : 
      35          57 : #define FD_SNAPSV_MSG_SNAP 1 /* fd_snapsv_msg_snap_t */
      36             : 
      37             : /* FD_SNAPSV_CLOSE_* give reasons an upload ended */
      38             : 
      39           3 : #define FD_SNAPSV_CLOSE_DONE  0 /* the whole requested range was sent */
      40           0 : #define FD_SNAPSV_CLOSE_NET   1 /* failed for arbitrary network reason */
      41           0 : #define FD_SNAPSV_CLOSE_ABORT 2 /* failed because we locally aborted */
      42             : 
      43             : /* fd_snapsv_conn_key_t identifies a snapshot server HTTP request.
      44             : 
      45             :    (kind_id,req_seq) is an app-wide unique request identifier across all
      46             :    live and historical requests.
      47             :    (kind_id,slot_idx) is app-wide unique among live/ongoing requests only. */
      48             : 
      49             : struct fd_snapsv_conn_key {
      50             :   uint  kind_id;  /* which snapsv tile? */
      51             :   ulong req_seq;  /* tile-unique HTTP request sequence number */
      52             :   uint  slot_idx; /* primary key (index of row in fixed size table) */
      53             : };
      54             : 
      55             : typedef struct fd_snapsv_conn_key fd_snapsv_conn_key_t;
      56             : 
      57             : /* fd_snapsv_msg_snap_t is an event for a snapshot GET request.
      58             : 
      59             :    frag_meta::
      60             :    - ctl::som: first frag of this request
      61             :    - ctl::eom: last frag of this request (request ended)
      62             : 
      63             :    For every snapshot GET request, there is at least one {som,eom} frag
      64             :    generated (might be the same frag), but they might get dropped due to
      65             :    mcache overruns. */
      66             : 
      67             : struct fd_snapsv_msg_snap {
      68             :   fd_snapsv_conn_key_t key;
      69             : 
      70             :   ulong slot;         /* snapshot slot */
      71             :   ulong base_slot;    /* ULONG_MAX if full snapshot */
      72             :   ulong snap_sz;      /* total snapshot file size */
      73             : 
      74             :   ulong req_off; /* file offset of HTTP Range request */
      75             :   ulong req_sz;  /* size of HTTP Range request */
      76             :   ulong req_cur; /* number of bytes sent or in send window */
      77             : 
      78             :   fd_ip6_addr_t req_ip;
      79             :   ushort        req_port;
      80             :   uchar         close_kind; /* FD_SNAPSV_CLOSE_* (valid if ctl.eom==1) */
      81             :   long          resp_ts;    /* timestamp of HTTP response start (unix nanoseconds) */
      82             : };
      83             : 
      84             : typedef struct fd_snapsv_msg_snap fd_snapsv_msg_snap_t;
      85             : 
      86             : /* fd_snapsv_msg_t is the data payload behind the fd_frag_meta_t::chunk
      87             :    compressed offset.  This type only exists to derive the link MTU. */
      88             : 
      89             : union fd_snapsv_msg {
      90             :   fd_snapsv_msg_snap_t snap;
      91             : };
      92             : 
      93             : typedef union fd_snapsv_msg fd_snapsv_msg_t;
      94             : 
      95             : #endif /* HEADER_fd_src_discof_backup_fd_snapsv_tile_h */

Generated by: LCOV version 1.14