123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2018-2021 Nomadic Labs. <nomadic@tezcore.com> *)(* Copyright (c) 2018-2020 Tarides <contact@tarides.com> *)(* Copyright (c) 2020 Metastate AG <hello@metastate.dev> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)typeerror+=|System_write_errorofstring|Bad_hashofstring*Bytes.t*Bytes.t|Context_not_foundofBytes.t|System_read_errorofstring|Inconsistent_snapshot_file|Inconsistent_snapshot_data|Missing_snapshot_data|Invalid_snapshot_versionofstring*stringlist|Restore_context_failure(* A hash that has been tagged with the kind of the value that it references
(either a node or a blob). *)moduletypeKinded_hash=sigtypettypehashvalencoding:tData_encoding.tendmoduletypeDump_interface=sigtypeindextypecontexttypetreetypehashtypecontents:=bytestypestep:=stringtypecommit_infotypebatchvalbatch:index->(batch->'aLwt.t)->'aLwt.tvalcommit_info_encoding:commit_infoData_encoding.tvalhash_equal:hash->hash->boolmoduleBlock_header:sigtypet=Block_header.tvalto_bytes:t->Bytes.tvalof_bytes:Bytes.t->toptionvalequal:t->t->boolvalencoding:tData_encoding.tendmoduleCommit_hash:sigtypetvalto_bytes:t->Bytes.tvalof_bytes:Bytes.t->ttzresultvalencoding:tData_encoding.tendmoduleKinded_hash:Kinded_hashwithtypehash:=hash(* Commit manipulation (for parents) *)valcontext_parents:context->Commit_hash.tlist(* Commit info *)valcontext_info:context->commit_info(* Retrieve context *)valcheckout:index->Commit_hash.t->contextoptionLwt.tvalset_context:info:commit_info->parents:Commit_hash.tlist->context->Commit_hash.t->boolLwt.t(* for dumping *)valcontext_tree:context->tree(* for restoring *)valmake_context:index->contextvalupdate_context:context->tree->contextvaladd_bytes:batch->bytes->treeLwt.tvaladd_dir:batch->(step*Kinded_hash.t,errortrace)Seq_es.t->(treeoption,errortrace)resultLwt.t(** This type exposes the internal nodes used in irmin in order to use them
during snapshot import and export. *)moduleSnapshot:sigtypekinded_hash=Contentsofhash*unit|Nodeofhashtypeentry={step:string;hash:kinded_hash}typeinode_tree={depth:int;length:int;pointers:(int*hash)list}typev=Inode_treeofinode_tree|Inode_valueofentrylisttypeinode={v:v;root:bool}typet=Inodeofinode|Blobofcontentsvalencoding:inodeData_encoding.tend(** [tree_iteri_unique ?on_disk index f tree] traverses
[tree], applying [f] to all inodes and contents.
[f] is called in post-order, that is [f] is first called on the
leaves, and the last call to [f] is on the root of the tree.
The traversal order is stable.
The traversal skips objects that are structurally equal to
objects that were already traversed. In other words,
[tree_iteri_unique] internally uses a hash set in order to
guarantee that all the objects passed to [f] don't hash the same
way.
If [on_disk] is true (by default its false), it uses an on_disk index.
Returns the total number of elements visited. *)valtree_iteri_unique:?on_disk:bool->index->(Snapshot.t->unitLwt.t)->tree->intLwt.ttypeimport(** [v_import ?in_memory index] creates an [importer] instance. If
[in_memory] is true, the import will be fully in memory.
[in_memory] is set to false by default. *)valv_import:?in_memory:bool->index->import(** [save_inode index importer elt] saves [elt] to the store. *)valsave_inode:index->import->Snapshot.t->treeoptionLwt.t(** [close importer] close the [importer] instance.*)valclose_import:import->index->unitendmoduletypeS=sigtypeindextypecontexttypeblock_headertypecontext_hashvalrestore_context_fd:index->expected_context_hash:context_hash->fd:Lwt_unix.file_descr->nb_context_elements:int->in_memory:bool->progress_display_mode:Animation.progress_display_mode->unittzresultLwt.tendmoduletypeContext_dump=sigmoduletypeDump_interface=Dump_interfacemoduletypeS=SmoduleMake(I:Dump_interface):Swithtypeindex:=I.indexandtypecontext:=I.contextandtypeblock_header:=I.Block_header.tandtypecontext_hash:=I.Commit_hash.tend