Mavryk_shell_context.Shell_context
Shell_context
is a persisting recursive map backed by an on-disk Irmin tree, i.e. Mavryk_context.Context
(in src/lib_context
), used by nodes. It is the "main" kind of context. It abstracts away Mavryk_context.Context
, by hiding the internals, and making it an instance of the generic Protocol_environment
.Context.t. Other *_context
modules of Mavryk_protocol_environment
, i.e. siblings of this file, are backed by different type of values coming from Mavryk_context
.
Shell_context
is one of the instances of Environment_context
along Memory_context
and Proxy_context
. All these 3 instances can implement the same API (i.e. Environment_context
), because this API is highly polymorphic, thanks to Environment_context
.Context.ops.
As such, a Shell_context
value is an instance of Environment_context
whose kind
is the one declared in this file.
Instances of Shell_context
are harder to obtain than Memory_context
ones, because they require a dedicated folder on disk (the subdirectory context
of the node's --data-dir
when it runs). As such, instances of Shell_context
are harder to initialize and use than Memory_context
; making them less amenable to testing for example.
The additional kind identifying Shell_context
values. Used to detect at runtime when a shell context is expected, to disambiguate from other kinds.
val checkout :
Mavryk_context.Context.index ->
Mavryk_base.TzPervasives.Context_hash.t ->
Mavryk_protocol_environment.Context.t option Lwt.t
checkout index ctxt_hash
checks whether the underlying data on disk contain an entry for ctxt_hash
. If so, it is returned; otherwise Nothing
is returned.
val checkout_exn :
Mavryk_context.Context.index ->
Mavryk_base.TzPervasives.Context_hash.t ->
Mavryk_protocol_environment.Context.t Lwt.t
checkout_exn index ctxt_hash
checks whether the underlying data on disk contain an entry for ctxt_hash
. If so, the data are loaded and returned; otherwise the exception thrown by Mavryk_context.Context.checkout_exn
is forwarded. Prefer using checkout
.
val wrap_disk_context :
Mavryk_context.Context.t ->
Mavryk_protocol_environment.Context.t
wrap_disk_context t
creates a shell context from an Irmin on-disk folder (i.e. Mavryk_context.Context.t
). This function hereby abstracts away a value, from the low-level lib_context
to the higher-level lib_protocol_environment
.
val unwrap_disk_context :
Mavryk_protocol_environment.Context.t ->
Mavryk_context.Context.t
unwrap_disk_context t
gives access to the lower-level Mavryk_context.Context.t
value underlying a Shell_context
.