1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2023 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. *)(* *)(*****************************************************************************)(* Conveniences to construct RPC directory
against a subcontext of the Node_context *)moduletypePARAM=sigtypeprefixtypecontexttypesubcontextvalcontext_of_prefix:context->prefix->subcontexttzresultLwt.tendmoduletypePARAM_PREFIX=sigincludePARAMvalprefix:(unit,prefix)Tezos_rpc.Path.tendmoduleMake_sub_directory(S:PARAM)=structopenSletdirectory:subcontexttzresultTezos_rpc.Directory.tref=refTezos_rpc.Directory.emptyletregisterservicef=directory:=Tezos_rpc.Directory.register!directoryservicefletregister0servicef=letopenLwt_result_syntaxinregister(Tezos_rpc.Service.subst0service)@@functxtqueryinput->let*?ctxtinfctxtqueryinputletregister1servicef=letopenLwt_result_syntaxinregister(Tezos_rpc.Service.subst1service)@@fun(ctxt,arg)queryinput->let*?ctxtinfctxtargqueryinputletbuild_sub_directorynode_ctxt=!directory|>Tezos_rpc.Directory.map(funprefix->context_of_prefixnode_ctxtprefix)letgen_registerservicef=directory:=Tezos_rpc.Directory.gen_register!directoryservicefletgen_register0servicef=gen_register(Tezos_rpc.Service.subst0service)@@functxtqueryinput->matchctxtwith|Errore->Tezos_rpc.Answer.faile|Okctxt->fctxtqueryinputendmoduleMake_directory(S:PARAM_PREFIX)=structincludeMake_sub_directory(S)letof_subdirectory=Tezos_rpc.Directory.prefixS.prefixletbuild_directorynode_ctxt=build_sub_directorynode_ctxt|>Tezos_rpc.Directory.prefixS.prefixend