| 
11 | 11 | {-# LANGUAGE ScopedTypeVariables #-}  | 
12 | 12 | {-# LANGUAGE TypeApplications #-}  | 
13 | 13 | 
 
  | 
14 |  | --- | Common logic and types for LedgerDB Snapshots.  | 
 | 14 | +-- | Snapshots  | 
15 | 15 | --  | 
16 |  | --- Snapshots are saved copies of Ledger states in the chain which can be used to  | 
17 |  | --- restart the node without having to replay the whole chain. Regardless of the  | 
18 |  | --- actual LedgerDB implementation chosen, the general management of snapshots is  | 
19 |  | --- common to all implementations.  | 
 | 16 | +-- Snapshotting a ledger state means saving a copy of the state to disk, so that  | 
 | 17 | +-- a later start of a cardano-node can use such a snapshot as a starting point  | 
 | 18 | +-- instead of having to replay from Genesis.  | 
 | 19 | +--  | 
 | 20 | +-- A snapshot is identified by the slot number of the ledger state it contains  | 
 | 21 | +-- and possibly has a suffix in the name. The consensus logic will not delete a  | 
 | 22 | +-- snapshot if it has a suffix. This can be used to store important  | 
 | 23 | +-- snapshots. The suffix can be manually added to the snapshot by renaming the  | 
 | 24 | +-- folder (see the caveats in 'snapshotManager' for the LSM backend). It will  | 
 | 25 | +-- also be added automatically by some tools such as db-analyser.  | 
 | 26 | +--  | 
 | 27 | +-- In general snapshots will be stored in the @./ledger@ directory inside the  | 
 | 28 | +-- ChainDB directory, but each LedgerDB backend is free to store it somewhere  | 
 | 29 | +-- else. Management of snapshots is done through the 'SnapshotManager'  | 
 | 30 | +-- record (see the 'snapshotManager' functions on each backend).  | 
 | 31 | +--  | 
 | 32 | +-- Snapshots cosists of two parts:  | 
 | 33 | +--  | 
 | 34 | +--  - the ledger state tables: location and format differs among backends,  | 
 | 35 | +--  | 
 | 36 | +--  - the rest of the ledger state: a CBOR serialization of an @ExtLedgerState  | 
 | 37 | +--    blk EmptyMK@, stored in the @./state@ file in the snapshot directory.  | 
 | 38 | +--  | 
 | 39 | +-- V2 backends will provide means of loading a snapshot via the method  | 
 | 40 | +-- 'newHandleFromSnapshot'. V1 backends load the snapshot directly in  | 
 | 41 | +-- 'initFromSnapshot'.  | 
20 | 42 | module Ouroboros.Consensus.Storage.LedgerDB.Snapshots  | 
21 | 43 |   ( -- * Snapshots  | 
22 | 44 |     CRCError (..)  | 
 | 
0 commit comments