123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)openData_encodingtypechain=[`Main|`Test|`HashofChain_id.t]letchain_arg=Block_services.chain_argletto_string=Block_services.chain_to_stringletparse_chain=Block_services.parse_chaintypeinvalid_block={hash:Block_hash.t;level:Int32.t;errors:errorlist}typeprefix=Block_services.chain_prefixletpath=Block_services.chain_pathletcheckpoint_encoding=obj4(req"block"(dynamic_sizeBlock_header.encoding))(req"savepoint"int32)(req"caboose"int32)(req"history_mode"History_mode.encoding)letblock_descriptor_encoding=obj2(req"block_hash"Block_hash.encoding)(req"level"int32)letinvalid_block_encoding=conv(fun{hash;level;errors}->(hash,level,errors))(fun(hash,level,errors)->{hash;level;errors})(obj3(req"block"Block_hash.encoding)(req"level"int32)(req"errors"Tezos_rpc.Error.encoding))letbootstrap_encoding=obj2(req"bootstrapped"Encoding.bool)(req"sync_state"Chain_validator_worker_state.sync_status_encoding)moduleS=structletpath:prefixTezos_rpc.Path.context=Tezos_rpc.Path.open_rootletchain_id=Tezos_rpc.Service.get_service~description:"The chain unique identifier."~query:Tezos_rpc.Query.empty~output:Chain_id.encodingTezos_rpc.Path.(path/"chain_id")(* DEPRECATED: use `chains/<CHAIN_ID>/levels/{checkpoint, savepoint,
caboose, history_mode}` instead. *)letcheckpoint=Tezos_rpc.Service.get_service~description:"DEPRECATED: use `../levels/{checkpoint, savepoint, caboose, \
history_mode}` instead. The current checkpoint for this chain."~query:Tezos_rpc.Query.empty~output:checkpoint_encodingTezos_rpc.Path.(path/"checkpoint")letis_bootstrapped=Tezos_rpc.Service.get_service~description:"The bootstrap status of a chain"~query:Tezos_rpc.Query.empty~output:bootstrap_encodingTezos_rpc.Path.(path/"is_bootstrapped")letbootstrapped_flag_encoding=letopenData_encodinginobj1(req"bootstrapped"bool)letforce_bootstrapped=Tezos_rpc.Service.patch_service~description:"Forcefully set the bootstrapped flag of the node"~query:Tezos_rpc.Query.empty~input:bootstrapped_flag_encoding~output:unitpathmoduleLevels=structletpath=Tezos_rpc.Path.(path/"levels")letcheckpoint=Tezos_rpc.Service.get_service~description:"The current checkpoint for this chain."~query:Tezos_rpc.Query.empty~output:block_descriptor_encodingTezos_rpc.Path.(path/"checkpoint")letsavepoint=Tezos_rpc.Service.get_service~description:"The current savepoint for this chain."~query:Tezos_rpc.Query.empty~output:block_descriptor_encodingTezos_rpc.Path.(path/"savepoint")letcaboose=Tezos_rpc.Service.get_service~description:"The current caboose for this chain."~query:Tezos_rpc.Query.empty~output:block_descriptor_encodingTezos_rpc.Path.(path/"caboose")endmoduleBlocks=structletlist_query=letopenTezos_rpc.Queryinquery(funlengthheadsmin_date->objectmethodlength=lengthmethodheads=headsmethodmin_date=min_dateend)|+opt_field"length"~descr:"The requested number of predecessors to return (per request; see \
next argument)."Tezos_rpc.Arg.uint(funx->x#length)|+multi_field"head"~descr:"An empty argument requests blocks starting with the current \
head. A non empty list allows to request one or more specific \
fragments of the chain."Block_hash.rpc_arg(funx->x#heads)|+opt_field"min_date"~descr:"When `min_date` is provided, blocks with a timestamp before \
`min_date` are filtered out. However, if the `length` parameter \
is also provided, then up to that number of predecessors will be \
returned regardless of their date."Time.Protocol.rpc_arg(funx->x#min_date)|>sealletpath=Tezos_rpc.Path.(path/"blocks")letlist=letopenData_encodinginTezos_rpc.Service.get_service~description:"Lists block hashes from '<chain>', up to the last checkpoint, \
sorted with decreasing fitness. Without arguments it returns the \
head of the chain. Optional arguments allow to return the list of \
predecessors of a given block or of a set of blocks."~query:list_query~output:(list(listBlock_hash.encoding))pathendmoduleInvalid_blocks=structletpath=Tezos_rpc.Path.(path/"invalid_blocks")letlist=Tezos_rpc.Service.get_service~description:"Lists blocks that have been declared invalid along with the errors \
that led to them being declared invalid."~query:Tezos_rpc.Query.empty~output:(listinvalid_block_encoding)pathletget=Tezos_rpc.Service.get_service~description:"The errors that appears during the block (in)validation."~query:Tezos_rpc.Query.empty~output:invalid_block_encodingTezos_rpc.Path.(path/:Block_hash.rpc_arg)letdelete=Tezos_rpc.Service.delete_service~description:"Remove an invalid block for the tezos storage"~query:Tezos_rpc.Query.empty~output:Data_encoding.emptyTezos_rpc.Path.(path/:Block_hash.rpc_arg)endendletmake_call0sctxtchainqp=lets=Tezos_rpc.Service.prefixpathsinTezos_rpc.Context.make_call1sctxtchainqpletmake_call1sctxtchainaqp=lets=Tezos_rpc.Service.prefixpathsinTezos_rpc.Context.make_call2sctxtchainaqpletchain_idctxt=letf=make_call0S.chain_idctxtinfun?(chain=`Main)()->matchchainwith`Hashh->Lwt.return_okh|_->fchain()()letcheckpointctxt?(chain=`Main)()=make_call0S.checkpointctxtchain()()moduleLevels=structletcheckpointctxt?(chain=`Main)()=make_call0S.Levels.checkpointctxtchain()()letsavepointctxt?(chain=`Main)()=make_call0S.Levels.savepointctxtchain()()letcaboosectxt?(chain=`Main)()=make_call0S.Levels.caboosectxtchain()()endmoduleBlocks=structletlistctxt=letf=make_call0S.Blocks.listctxtinfun?(chain=`Main)?(heads=[])?length?min_date()->fchain(objectmethodheads=headsmethodlength=lengthmethodmin_date=min_dateend)()includeBlock_services.Emptytypeprotocols=Block_services.protocols={current_protocol:Protocol_hash.t;next_protocol:Protocol_hash.t;}letprotocols=Block_services.protocolsendmoduleMempool=Block_services.Empty.MempoolmoduleInvalid_blocks=structletlistctxt=letf=make_call0S.Invalid_blocks.listctxtinfun?(chain=`Main)()->fchain()()letgetctxt=letf=make_call1S.Invalid_blocks.getctxtinfun?(chain=`Main)block->fchainblock()()letdeletectxt=letf=make_call1S.Invalid_blocks.deletectxtinfun?(chain=`Main)block->fchainblock()()end