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

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_backup_fd_ssmanifest_writer_h
       2             : #define HEADER_fd_src_discof_backup_fd_ssmanifest_writer_h
       3             : 
       4             : /* fd_ssmanifest_writer.h provides streaming serialization of a Solana
       5             :    snapshot manifest. */
       6             : 
       7             : #include "../../flamenco/accdb/fd_accdb.h"
       8             : #include "../../flamenco/runtime/fd_bank.h"
       9             : 
      10             : /* fd_ssmanifest_epoch_vote_t is a vote account of an epoch stakes set
      11             :    that has an authorized voter for the set's epoch.  Agave lists these
      12             :    per node (node_id_to_vote_accounts) and per voter
      13             :    (epoch_authorized_voters) next to the set. */
      14             : 
      15             : struct fd_ssmanifest_epoch_vote {
      16             :   fd_pubkey_t vote;
      17             :   fd_pubkey_t node;
      18             :   fd_pubkey_t voter;
      19             :   ulong       stake;
      20             : };
      21             : 
      22             : typedef struct fd_ssmanifest_epoch_vote fd_ssmanifest_epoch_vote_t;
      23             : 
      24             : struct fd_ssmanifest_epoch_map {
      25             :   ulong                      vote_cnt;
      26             :   ulong                      node_cnt; /* distinct nodes in vote */
      27             :   fd_ssmanifest_epoch_vote_t vote[ FD_RUNTIME_MAX_VAT_VOTE_ACCOUNTS ]; /* sorted by node */
      28             : };
      29             : 
      30             : typedef struct fd_ssmanifest_epoch_map fd_ssmanifest_epoch_map_t;
      31             : 
      32             : struct fd_ssmanifest_writer {
      33             :   uint        state;
      34             :   fd_bank_t * bank;
      35             :   fd_pubkey_t leader; /* slot leader of the bank */
      36             :   uchar       epoch_idx;
      37             :   uchar       epoch_cnt;
      38             :   uint        vote_cnt;
      39             :   uint        vote_idx;
      40             :   ulong       total_stake;
      41             :   ulong       serialized_sz;
      42             :   uchar       vote_stakes_iter_mem[ FD_VOTE_STAKES_ITER_FOOTPRINT ] __attribute__((aligned(FD_VOTE_STAKES_ITER_ALIGN)));
      43             :   fd_ssmanifest_epoch_map_t epoch_map[ FD_RUNTIME_MANIFEST_EPOCH_STAKES_LEN ];
      44             : };
      45             : 
      46             : typedef struct fd_ssmanifest_writer fd_ssmanifest_writer_t;
      47             : 
      48             : FD_PROTOTYPES_BEGIN
      49             : 
      50             : /* fd_ssmanifest_writer_init creates a new snapshot manifest writer.
      51             :    leader is the slot leader of bank.  Reads the vote account of every
      52             :    epoch stakes entry from accdb at accdb_fork_id to fill the epoch
      53             :    maps.  acc_data is scratch of at least FD_RUNTIME_ACC_SZ_MAX bytes.
      54             :    Sets writer->serialized_sz.  Guaranteed to succeed for a valid
      55             :    bank. */
      56             : 
      57             : fd_ssmanifest_writer_t *
      58             : fd_ssmanifest_writer_init( fd_ssmanifest_writer_t * writer,
      59             :                            fd_bank_t *              bank,
      60             :                            fd_pubkey_t const *      leader,
      61             :                            fd_accdb_t *             accdb,
      62             :                            fd_accdb_fork_id_t       accdb_fork_id,
      63             :                            uchar *                  acc_data );
      64             : 
      65             : /* fd_snap_manifest_serialize serializes up to buf_sz worth of snapshot
      66             :    manifest data into out_buf.  Returns the number of bytes written.
      67             :    Returns 0UL if the manifest was fully serialized out, after which
      68             :    the writer is ready to serialize it again.  Typical usage:
      69             : 
      70             :      uchar out_buf[ FD_SSMANIFEST_BUF_MIN ];
      71             :      for(;;) {
      72             :        ulong sz = fd_snap_manifest_serialize( enc, out_buf, sizeof(out_buf) );
      73             :        if( !sz ) break;
      74             :        fd_io_write( ... ); // write out chunk
      75             :      }
      76             : 
      77             :    Produces 1 GiB-ish data for a mainnet snapshot. */
      78             : 
      79           0 : #define FD_SSMANIFEST_BUF_MIN (32UL<<20)
      80             : ulong
      81             : fd_snap_manifest_serialize( fd_ssmanifest_writer_t * enc,
      82             :                             uchar out_buf[ FD_SSMANIFEST_BUF_MIN ],
      83             :                             ulong buf_sz );
      84             : 
      85             : FD_PROTOTYPES_END
      86             : 
      87             : #endif /* HEADER_fd_src_discof_backup_fd_ssmanifest_writer_h */

Generated by: LCOV version 1.14