123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* 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. *)(* *)(*****************************************************************************)letof_memory_tree(t:Tezos_context_memory.Context.tree):Tezos_protocol_environment.Proxy_delegate.t=(modulestructletproxy_dir_memkey=letopenLwt_syntaxinlet*v=Tezos_context_memory.Context.Tree.mem_treetkeyinreturn_okvletproxy_getkey=letopenLwt_syntaxinlet*v=Tezos_context_memory.Context.Tree.find_treetkeyinreturn_okvletproxy_memkey=letopenLwt_syntaxinlet*v=Tezos_context_memory.Context.Tree.memtkeyinreturn_okvend:Tezos_protocol_environment.Proxy_delegate.T)letof_memory_context(m:Tezos_context_memory.Context.t):Tezos_protocol_environment.Proxy_delegate.t=(modulestructletproxy_dir_memkey=letopenLwt_syntaxinlet*v=Tezos_context_memory.Context.mem_treemkeyinreturn_okvletproxy_getkey=letopenLwt_syntaxinlet*v=Tezos_context_memory.Context.find_treemkeyinreturn_okvletproxy_memkey=letopenLwt_syntaxinlet*v=Tezos_context_memory.Context.memmkeyinreturn_okvend:Tezos_protocol_environment.Proxy_delegate.T)letmake_index~(context_path:string):Tezos_context.Context.indexLwt.t=Tezos_context.Context.init~readonly:truecontext_pathletof_index~(index:Tezos_context.Context.index)(hash:Tezos_crypto.Hashed.Context_hash.t):Tezos_protocol_environment.Proxy_delegate.ttzresultLwt.t=letopenLwt_syntaxinlet*ctxt=Tezos_context.Context.checkoutindexhashinmatchctxtwith|None->failwith"Couldn't check out the hash %s"(Tezos_crypto.Hashed.Context_hash.to_stringhash)|Somectxt->letproxy_data_dir:Tezos_protocol_environment.Proxy_delegate.t=(modulestructletproxy_dir_mem(key:Tezos_context.Context.key):booltzresultLwt.t=let*(res:bool)=Tezos_context.Context.mem_treectxtkeyinreturn_okresletproxy_get(key:Tezos_context.Context.key):Tezos_context_memory.Context.treeoptiontzresultLwt.t=let*res=Tezos_context.Context.to_memory_treectxtkeyinreturn_okresletproxy_mem(key:Tezos_context.Context.key):booltzresultLwt.t=let*res=Tezos_context.Context.memctxtkeyinreturn_okresend)inreturn_okproxy_data_dir