12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2018-2021 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. *)(* *)(*****************************************************************************)letbuild_rpc_directoryblock_validatorstore=letopenLwt_result_syntaxinletdir:unitTezos_rpc.Directory.tref=refTezos_rpc.Directory.emptyinletgen_register0sf=dir:=Tezos_rpc.Directory.gen_register!dirs(fun()pq->fpq)inletregister1sf=dir:=Tezos_rpc.Directory.register!dirs(fun((),a)pq->fapq)ingen_register0Protocol_services.S.list(fun()()->letset=Store.Protocol.allstoreinletprotocols=Protocol_hash.Set.add_seq(Registered_protocol.seq_embedded())setinTezos_rpc.Answer.return(Protocol_hash.Set.elementsprotocols));register1Protocol_services.S.contents(funhash()()->matchRegistered_protocol.get_embedded_sourceshashwith|Somep->returnp|None->(let*!o=Store.Protocol.readstorehashinmatchowithNone->fail_with_exnNot_found|Somep->returnp));register1Protocol_services.S.environment(funhash()()->matchRegistered_protocol.get_embedded_sourceshashwith|Somep->returnp.expected_env|None->(let*!o=Store.Protocol.readstorehashinmatchowith|None->fail_with_exnNot_found|Somep->returnp.expected_env));register1Protocol_services.S.fetch(funhash()()->let*_proto=Block_validator.fetch_and_compile_protocolblock_validatorhashinreturn_unit);!dir