Module Mavkit_smart_rollup_node.Snapshot_utils

Snapshot archives creation and extraction

type reader

The type of snapshot archive readers.

type writer

The type of snapshot archive writers.

val stdlib_reader : reader

A reader for uncompressed files or snapshot archives.

val stdlib_writer : writer

A writer for uncompressed files or snapshot archives.

val gzip_reader : reader

A reader for compressed files or snapshot archives.

val gzip_writer : writer

A writer for compressed files or snapshot archives.

type snapshot_version =
  1. | V0

Versioning of snapshot format. Only one version for now.

type snapshot_metadata = {
  1. history_mode : Configuration.history_mode;
  2. address : Mavkit_smart_rollup.Address.t;
  3. head_level : int32;
  4. last_commitment : Mavkit_smart_rollup.Commitment.Hash.t;
}

Snapshot metadata for version 0. This information is written as a header of the archive snapshot file.

val create : reader -> writer -> snapshot_metadata -> dir:string -> include_file:(relative_path:string -> bool) -> dest:string -> unit

create reader writer metadata ~dir ~include_file ~dest creates a snapshot archive with the header metadata and the hierarchy of files in directory dir for which include_file returns true. The archive is produced in file dest.

val extract : reader -> writer -> (snapshot_metadata -> unit Mavryk_base.TzPervasives.tzresult Lwt.t) -> snapshot_file:string -> dest:string -> snapshot_metadata Mavryk_base.TzPervasives.tzresult Lwt.t

extract reader writer check_metadata ~snapshot_file ~dest extracts the snapshot archive snapshot_file in the directory dest. Existing files in dest with the same names are overwritten. The metadata header read from the snapshot is checked with check_metadata before beginning extraction, and returned.

val compress : snapshot_file:string -> string

compress ~snapshot_file compresses the snapshot archive snapshot_file of the form "path/to/snapshot.uncompressed" to a new file "path/to/snapshot" whose path is returned. snapshot_file is removed upon successful compression.

val read_metadata : reader -> snapshot_file:string -> snapshot_metadata

read_metadata reader ~snapshot_file reads the metadata from the snapshot file without extracting it.

val copy_file : src:string -> dst:string -> unit

copy_file ~src ~dst copies the file src to dst.

val copy_dir : ?perm:int -> string -> string -> unit

copy_dir ?perm src dst copies the content of directory src in the directory dst (created with perm, 0o755 by default).