Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_snapshot_fd_snapshot_h 2 : #define HEADER_fd_src_flamenco_snapshot_fd_snapshot_h 3 : 4 : #if FD_HAS_ZSTD 5 : 6 : /* fd_snapshot.h provides high-level blocking APIs for Solana snapshots. */ 7 : 8 : #include "fd_snapshot_base.h" 9 : 10 : FD_PROTOTYPES_BEGIN 11 : 12 : /* Whether to initialize these objects inside fd_snapshot_load_manifest_and_status_cache, 13 : or just advance the tar cursor. */ 14 0 : #define FD_SNAPSHOT_RESTORE_NONE (0) 15 0 : #define FD_SNAPSHOT_RESTORE_MANIFEST (1) 16 0 : #define FD_SNAPSHOT_RESTORE_STATUS_CACHE (2) 17 : 18 : struct fd_snapshot_load_ctx; 19 : typedef struct fd_snapshot_load_ctx fd_snapshot_load_ctx_t; 20 : 21 : /* fd_snapshot_load_all does a blocking load of a snapshot. It is a wrapper 22 : around fd_snapshot_load_new, fd_snapshot_load_init, 23 : fd_snapshot_load_manifest_and_status_cache, and fd_snapshot_load_fini. 24 : 25 : fd_snapshot_load_new sets up the context that is passed around for the 26 : other fd_snapshot_load_* functions. 27 : 28 : fd_snapshot_load_init starts the process of loading in the snapshot and 29 : sets up the funk transactions, etc.. 30 : 31 : fd_snapshot_load_manifest_and_status_cache loads in the manifest and the 32 : status cache exiting as soon as the manifest is loaded in. 33 : 34 : fd_snapshot_load_accounts will load in the rest of the snapshot file but 35 : the runtime is still not setup to run. 36 : 37 : fd_snapshot_load_fini will use the slot context and funk which are now 38 : populated to setup the runtime and finalize the snapshot load. 39 : 40 : The reason these are broken out is to support loading in the manifest as 41 : quickly as possible, allowing for other operations to start (like 42 : stake-weighted repair) while the rest of the snapshot is being loaded. This 43 : is needed as loading in the manifest only takes a few seconds and the overall 44 : time to load in a snapshot is dominated by loading in the append vecs. 45 : 46 : source_cstr is either a local file system path. 47 : TODO: Add support for an HTTP url. 48 : 49 : slot_ctx is a valid initialized slot context. 50 : 51 : spad should have enough space to buffer the snapshot's manifest. 52 : 53 : If verify_hash!=0 calculates the snapshot hash. 54 : 55 : If check_hash!=0 checks that the snapshot hash matches the file name. 56 : 57 : snapshot_type is one of FD_SNAPSHOT_TYPE_{...}. */ 58 : 59 : ulong 60 : fd_snapshot_load_ctx_align( void ); 61 : 62 : ulong 63 : fd_snapshot_load_ctx_footprint( void ); 64 : 65 : fd_snapshot_load_ctx_t * 66 : fd_snapshot_load_new( uchar * mem, 67 : const char * snapshot_file, 68 : fd_exec_slot_ctx_t * slot_ctx, 69 : fd_tpool_t * tpool, 70 : uint verify_hash, 71 : uint check_hash, 72 : int snapshot_type, 73 : fd_spad_t * * exec_spads, 74 : ulong spad_cnt, 75 : fd_spad_t * runtime_spad ); 76 : 77 : void 78 : fd_snapshot_load_init( fd_snapshot_load_ctx_t * ctx ); 79 : 80 : /* restore_manifest_flags controls if the manifest and status cache objects are initialized or not. */ 81 : void 82 : fd_snapshot_load_manifest_and_status_cache( fd_snapshot_load_ctx_t * ctx, 83 : ulong * base_slot_override, 84 : int restore_manifest_flags ); 85 : 86 : void 87 : fd_snapshot_load_accounts( fd_snapshot_load_ctx_t * ctx ); 88 : 89 : void 90 : fd_snapshot_load_fini( fd_snapshot_load_ctx_t * ctx ); 91 : 92 : void 93 : fd_snapshot_load_all( const char * source_cstr, 94 : fd_exec_slot_ctx_t * slot_ctx, 95 : ulong * base_slot_override, 96 : fd_tpool_t * tpool, 97 : uint verify_hash, 98 : uint check_hash, 99 : int snapshot_type, 100 : fd_spad_t * * exec_spads, 101 : ulong exec_spad_cnt, 102 : fd_spad_t * runtime_spad ); 103 : 104 : void 105 : fd_snapshot_load_prefetch_manifest( fd_snapshot_load_ctx_t * ctx ); 106 : 107 : ulong 108 : fd_snapshot_get_slot( fd_snapshot_load_ctx_t * ctx ); 109 : 110 : FD_PROTOTYPES_END 111 : 112 : #endif /* FD_HAS_ZSTD */ 113 : 114 : #endif /* HEADER_fd_src_flamenco_snapshot_fd_snapshot_h */