LCOV - code coverage report
Current view: top level - discof/restore - fd_snaprd_tile.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 39 0.0 %
Date: 2025-10-13 04:42:14 Functions: 0 9 0.0 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_restore_fd_snaprd_tile_h
       2             : #define HEADER_fd_src_discof_restore_fd_snaprd_tile_h
       3             : 
       4             : #include "../../util/fd_util_base.h"
       5             : 
       6             : /* The snaprd 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 snaprd tile gathers the latest SnapshotHashes information from
      10             :    gossip to decide whether to download snapshots or read local
      11             :    snapshots from disk.  If the snaprd 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_SNAPRD_STATE_WAITING_FOR_PEERS               ( 0) /* Waiting for first peer to arrive from gossip to download from */
      16           0 : #define FD_SNAPRD_STATE_WAITING_FOR_PEERS_INCREMENTAL   ( 1) /* Waiting for peers when attempting to download an incremental snapshot */
      17           0 : #define FD_SNAPRD_STATE_COLLECTING_PEERS                ( 2) /* First peer arrived, wait a little longer to see if a better one arrives */
      18           0 : #define FD_SNAPRD_STATE_COLLECTING_PEERS_INCREMENTAL    ( 3) /* Collecting peers to download an incremental snapshot */
      19           0 : #define FD_SNAPRD_STATE_READING_FULL_FILE               ( 4) /* Full file looks better than peer, reading it from disk */
      20           0 : #define FD_SNAPRD_STATE_FLUSHING_FULL_FILE              ( 5) /* Full file was read ok, confirm it decompressed and inserted ok */
      21           0 : #define FD_SNAPRD_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_SNAPRD_STATE_READING_INCREMENTAL_FILE        ( 7) /* Incremental file looks better than peer, reading it from disk */
      23           0 : #define FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_FILE       ( 8) /* Incremental file was read ok, confirm it decompressed and inserted ok */
      24           0 : #define FD_SNAPRD_STATE_READING_FULL_HTTP               ( 9) /* Peer was selected, reading full snapshot from HTTP */
      25           0 : #define FD_SNAPRD_STATE_FLUSHING_FULL_HTTP              (10) /* Full snapshot was downloaded ok, confirm it decompressed and inserted ok */
      26           0 : #define FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET        (11) /* Resetting to load full snapshot from HTTP again, confirm decompress and inserter are reset too */
      27           0 : #define FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_HTTP_RESET (12) /* Resetting to load incremental snapshot from HTTP again, confirm decompress and inserter are reset too */
      28           0 : #define FD_SNAPRD_STATE_READING_INCREMENTAL_HTTP        (13) /* Peer was selected, reading incremental snapshot from HTTP */
      29           0 : #define FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_HTTP       (14) /* Incremental snapshot was downloaded ok, confirm it decompressed and inserted ok */
      30           0 : #define FD_SNAPRD_STATE_SHUTDOWN                        (15) /* The tile is done, and has likely already exited */
      31             : 
      32             : static inline const char *
      33           0 : fd_snaprd_state_str( ulong state ) {
      34           0 :   switch( state ) {
      35           0 :     case FD_SNAPRD_STATE_WAITING_FOR_PEERS:               return "waiting_for_peers";
      36           0 :     case FD_SNAPRD_STATE_WAITING_FOR_PEERS_INCREMENTAL:   return "waiting_for_peers_incremental";
      37           0 :     case FD_SNAPRD_STATE_COLLECTING_PEERS:                return "collecting_peers";
      38           0 :     case FD_SNAPRD_STATE_COLLECTING_PEERS_INCREMENTAL:    return "collecting_peers_incremental";
      39           0 :     case FD_SNAPRD_STATE_READING_FULL_FILE:               return "reading_full_file";
      40           0 :     case FD_SNAPRD_STATE_FLUSHING_FULL_FILE:              return "flushing_full_file";
      41           0 :     case FD_SNAPRD_STATE_FLUSHING_FULL_FILE_RESET:        return "flushing_full_file_reset";
      42           0 :     case FD_SNAPRD_STATE_READING_INCREMENTAL_FILE:        return "reading_incremental_file";
      43           0 :     case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_FILE:       return "flushing_incremental_file";
      44           0 :     case FD_SNAPRD_STATE_READING_FULL_HTTP:               return "reading_full_http";
      45           0 :     case FD_SNAPRD_STATE_FLUSHING_FULL_HTTP:              return "flushing_full_http";
      46           0 :     case FD_SNAPRD_STATE_FLUSHING_FULL_HTTP_RESET:        return "flushing_full_http_reset";
      47           0 :     case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_HTTP_RESET: return "flushing_incremental_http_reset";
      48           0 :     case FD_SNAPRD_STATE_READING_INCREMENTAL_HTTP:        return "reading_incremental_http";
      49           0 :     case FD_SNAPRD_STATE_FLUSHING_INCREMENTAL_HTTP:       return "flushing_incremental_http";
      50           0 :     case FD_SNAPRD_STATE_SHUTDOWN:                        return "shutdown";
      51           0 :     default:                                              return "unknown";
      52           0 :   }
      53           0 : }
      54             : 
      55           0 : #define FD_SNAPRD_SNAPSHOT_TYPE_FULL        (0)
      56           0 : #define FD_SNAPRD_SNAPSHOT_TYPE_INCREMENTAL (1)
      57             : 
      58             : typedef struct {
      59             :   int type;
      60             :   int is_download;
      61             :   char read_path[ PATH_MAX ];
      62             : } fd_snaprd_update_t;
      63             : 
      64             : #endif /* HEADER_fd_src_discof_restore_fd_snaprd_tile_h */

Generated by: LCOV version 1.14