1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.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. *)(* *)(*****************************************************************************)openAlpha_contexttyperpc_context={block_hash:Block_hash.t;block_header:Block_header.shell_header;context:Alpha_context.t;}letrpc_init({block_hash;block_header;context}:Updater.rpc_context)=letlevel=block_header.levelinlettimestamp=block_header.timestampinletfitness=block_header.fitnessinAlpha_context.prepare~level~predecessor_timestamp:timestamp~timestamp~fitnesscontext>>=?funcontext->return{block_hash;block_header;context}letrpc_services=ref(RPC_directory.empty:Updater.rpc_contextRPC_directory.t)letregister0_fullctxtsf=rpc_services:=RPC_directory.register!rpc_servicess(functxtqi->rpc_initctxt>>=?functxt->fctxtqi)letopt_register0_fullctxtsf=rpc_services:=RPC_directory.opt_register!rpc_servicess(functxtqi->rpc_initctxt>>=?functxt->fctxtqi)letregister0sf=register0_fullctxts(fun{context;_}->fcontext)letregister0_noctxtsf=rpc_services:=RPC_directory.register!rpc_servicess(fun_qi->fqi)letregister1_fullctxtsf=rpc_services:=RPC_directory.register!rpc_servicess(fun(ctxt,arg)qi->rpc_initctxt>>=?functxt->fctxtargqi)letregister1sf=register1_fullctxts(fun{context;_}x->fcontextx)letregister1_noctxtsf=rpc_services:=RPC_directory.register!rpc_servicess(fun(_,arg)qi->fargqi)letregister2_fullctxtsf=rpc_services:=RPC_directory.register!rpc_servicess(fun((ctxt,arg1),arg2)qi->rpc_initctxt>>=?functxt->fctxtarg1arg2qi)letregister2sf=register2_fullctxts(fun{context;_}a1a2qi->fcontexta1a2qi)letget_rpc_services()=letp=RPC_directory.map(func->rpc_initc>>=function|Error_->assertfalse|Okc->Lwt.returnc.context)(Storage_description.build_directoryAlpha_context.description)inRPC_directory.register_dynamic_directory!rpc_servicesRPC_path.(open_root/"context"/"raw"/"json")(fun_->Lwt.returnp)