LCOV - code coverage report
Current view: top level - discof/restore - fd_snapct_tile.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 41 0.0 %
Date: 2025-10-27 04:40:00 Functions: 0 9 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_restore_fd_snapct_tile_h
       2             : #define HEADER_fd_src_discof_restore_fd_snapct_tile_h
       3             : 
       4             : #include "../../util/fd_util_base.h"
       5             : 
       6             : /* The snapct tile at a high level is a state machine that downloads
       7             :    snapshots from the network or reads snapshots from disk and produces
       8             :    a byte stream that is parsed by downstream snapshot consumer tiles.
       9             :    The snapct tile gathers the latest SnapshotHashes information from
      10             :    gossip to decide whether to download snapshots or read local
      11             :    snapshots from disk.  If the snapct tile needs to download a snapshot,
      12             :    it goes through the process of discovering and selecting elegible
      13             :    peers from gossip to download from. */
      14             : 
      15           0 : #define FD_SNAPCT_STATE_WAITING_FOR_PEERS               ( 0) /* Waiting for first peer to arrive from gossip to download from */
      16           0 : #define FD_SNAPCT_STATE_WAITING_FOR_PEERS_INCREMENTAL   ( 1) /* Waiting for peers when attempting to download an incremental snapshot */
      17           0 : #define FD_SNAPCT_STATE_COLLECTING_PEERS                ( 2) /* First peer arrived, wait a little longer to see if a better one arrives */
      18           0 : #define FD_SNAPCT_STATE_COLLECTING_PEERS_INCREMENTAL    ( 3) /* Collecting peers to download an incremental snapshot */
      19           0 : #define FD_SNAPCT_STATE_READING_FULL_FILE               ( 4) /* Full file looks better than peer, reading it from disk */
      20           0 : #define FD_SNAPCT_STATE_FLUSHING_FULL_FILE              ( 5) /* Full file was read ok, confirm it decompressed and inserted ok */
      21           0 : #define FD_SNAPCT_STATE_FLUSHING_FULL_FILE_RESET        ( 6) /* Resetting to load full snapshot from file again, confirm decompress and inserter are reset too */
      22           0 : #define FD_SNAPCT_STATE_READING_INCREMENTAL_FILE        ( 7) /* Incremental file looks better than peer, reading it from disk */
      23           0 : #define FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_FILE       ( 8) /* Incremental file was read ok, confirm it decompressed and inserted ok */
      24           0 : #define FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_FILE_RESET ( 9) /* Resetting to load incremental snapshot from file again, confirm decompress and inserter are reset too */
      25           0 : #define FD_SNAPCT_STATE_READING_FULL_HTTP               (10) /* Peer was selected, reading full snapshot from HTTP */
      26           0 : #define FD_SNAPCT_STATE_FLUSHING_FULL_HTTP              (11) /* Full snapshot was downloaded ok, confirm it decompressed and inserted ok */
      27           0 : #define FD_SNAPCT_STATE_FLUSHING_FULL_HTTP_RESET        (12) /* Resetting to load full snapshot from HTTP again, confirm decompress and inserter are reset too */
      28           0 : #define FD_SNAPCT_STATE_READING_INCREMENTAL_HTTP        (13) /* Peer was selected, reading incremental snapshot from HTTP */
      29           0 : #define FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_HTTP       (14) /* Incremental snapshot was downloaded ok, confirm it decompressed and inserted ok */
      30           0 : #define FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_HTTP_RESET (15) /* Resetting to load incremental snapshot from HTTP again, confirm decompress and inserter are reset too */
      31           0 : #define FD_SNAPCT_STATE_SHUTDOWN                        (16) /* The tile is done, and has likely already exited */
      32             : 
      33             : static inline const char *
      34           0 : fd_snapct_state_str( ulong state ) {
      35           0 :   switch( state ) {
      36           0 :     case FD_SNAPCT_STATE_WAITING_FOR_PEERS:               return "waiting_for_peers";
      37           0 :     case FD_SNAPCT_STATE_WAITING_FOR_PEERS_INCREMENTAL:   return "waiting_for_peers_incremental";
      38           0 :     case FD_SNAPCT_STATE_COLLECTING_PEERS:                return "collecting_peers";
      39           0 :     case FD_SNAPCT_STATE_COLLECTING_PEERS_INCREMENTAL:    return "collecting_peers_incremental";
      40           0 :     case FD_SNAPCT_STATE_READING_FULL_FILE:               return "reading_full_file";
      41           0 :     case FD_SNAPCT_STATE_FLUSHING_FULL_FILE:              return "flushing_full_file";
      42           0 :     case FD_SNAPCT_STATE_FLUSHING_FULL_FILE_RESET:        return "flushing_full_file_reset";
      43           0 :     case FD_SNAPCT_STATE_READING_INCREMENTAL_FILE:        return "reading_incremental_file";
      44           0 :     case FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_FILE:       return "flushing_incremental_file";
      45           0 :     case FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_FILE_RESET: return "flushing_incremental_file_reset";
      46           0 :     case FD_SNAPCT_STATE_READING_FULL_HTTP:               return "reading_full_http";
      47           0 :     case FD_SNAPCT_STATE_FLUSHING_FULL_HTTP:              return "flushing_full_http";
      48           0 :     case FD_SNAPCT_STATE_FLUSHING_FULL_HTTP_RESET:        return "flushing_full_http_reset";
      49           0 :     case FD_SNAPCT_STATE_READING_INCREMENTAL_HTTP:        return "reading_incremental_http";
      50           0 :     case FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_HTTP:       return "flushing_incremental_http";
      51           0 :     case FD_SNAPCT_STATE_FLUSHING_INCREMENTAL_HTTP_RESET: return "flushing_incremental_http_reset";
      52           0 :     case FD_SNAPCT_STATE_SHUTDOWN:                        return "shutdown";
      53           0 :     default:                                              return "unknown";
      54           0 :   }
      55           0 : }
      56             : 
      57           0 : #define FD_SNAPCT_SNAPSHOT_TYPE_FULL        (0)
      58           0 : #define FD_SNAPCT_SNAPSHOT_TYPE_INCREMENTAL (1)
      59             : 
      60             : typedef struct {
      61             :   int type;
      62             :   int is_download;
      63             :   char read_path[ PATH_MAX ];
      64             : } fd_snapct_update_t;
      65             : 
      66             : #endif /* HEADER_fd_src_discof_restore_fd_snapct_tile_h */

Generated by: LCOV version 1.14