123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)typechain_status=|Active_mainofChain_id.t|Active_testof{chain:Chain_id.t;protocol:Protocol_hash.t;expiration_date:Time.Protocol.t;}|StoppingofChain_id.tletchain_status_encoding=letopenData_encodinginunion~tag_size:`Uint8[case(Tag0)~title:"Main"(obj1(req"chain_id"Chain_id.encoding))(functionActive_mainchain_id->Somechain_id|_->None)(funchain_id->Active_mainchain_id);case(Tag1)~title:"Test"(obj3(req"chain_id"Chain_id.encoding)(req"test_protocol"Protocol_hash.encoding)(req"expiration_date"Time.Protocol.encoding))(function|Active_test{chain;protocol;expiration_date}->Some(chain,protocol,expiration_date)|_->None)(fun(chain,protocol,expiration_date)->Active_test{chain;protocol;expiration_date});case(Tag2)~title:"Stopping"(obj1(req"stopping"Chain_id.encoding))(functionStoppingchain_id->Somechain_id|_->None)(funchain_id->Stoppingchain_id);]moduleS=structopenData_encodingletpath=Tezos_rpc.Path.(root/"monitor")letbootstrapped=Tezos_rpc.Service.get_service~description:"Wait for the node to have synchronized its chain with a few peers \
(configured by the node's administrator), streaming head updates that \
happen during the bootstrapping process, and closing the stream at \
the end. If the node was already bootstrapped, returns the current \
head immediately."~query:Tezos_rpc.Query.empty~output:(obj2(req"block"Block_hash.encoding)(req"timestamp"Time.Protocol.encoding))Tezos_rpc.Path.(path/"bootstrapped")letvalidated_or_apply_blocks_query=letopenTezos_rpc.Queryinquery(funprotocolsnext_protocolschains->objectmethodprotocols=protocolsmethodnext_protocols=next_protocolsmethodchains=chainsend)|+multi_field"protocol"Protocol_hash.rpc_arg(funt->t#protocols)|+multi_field"next_protocol"Protocol_hash.rpc_arg(funt->t#next_protocols)|+multi_field"chain"Chain_services.chain_arg(funt->t#chains)|>sealletvalidated_blocks=Tezos_rpc.Service.get_service~description:"Monitor all blocks that were successfully validated by the node but \
are not applied nor stored yet, disregarding whether they are going \
to be selected as the new head or not."~query:validated_or_apply_blocks_query~output:(obj4(req"chain_id"Chain_id.encoding)(req"hash"Block_hash.encoding)(req"header"(dynamic_sizeBlock_header.encoding))(req"operations"(list(list(dynamic_sizeOperation.encoding)))))Tezos_rpc.Path.(path/"validated_blocks")letapplied_blocks=Tezos_rpc.Service.get_service~description:"Monitor all blocks that are successfully applied and stored by the \
node, disregarding whether they were selected as the new head or not."~query:validated_or_apply_blocks_query~output:(obj4(req"chain_id"Chain_id.encoding)(req"hash"Block_hash.encoding)(req"header"(dynamic_sizeBlock_header.encoding))(req"operations"(list(list(dynamic_sizeOperation.encoding)))))Tezos_rpc.Path.(path/"applied_blocks")letheads_query=letopenTezos_rpc.Queryinquery(funprotocolsnext_protocols->objectmethodprotocols=protocolsmethodnext_protocols=next_protocolsend)|+multi_field"protocol"Protocol_hash.rpc_arg(funt->t#protocols)|+multi_field"next_protocol"Protocol_hash.rpc_arg(funt->t#next_protocols)|>sealletheads=Tezos_rpc.Service.get_service~description:"Monitor all blocks that are successfully validated and applied by the \
node and selected as the new head of the given chain."~query:heads_query~output:(merge_objs(obj1(req"hash"Block_hash.encoding))Block_header.encoding)Tezos_rpc.Path.(path/"heads"/:Chain_services.chain_arg)letprotocols=Tezos_rpc.Service.get_service~description:"Monitor all economic protocols that are retrieved and successfully \
loaded and compiled by the node."~query:Tezos_rpc.Query.empty~output:Protocol_hash.encodingTezos_rpc.Path.(path/"protocols")(* DEPRECATED: use [version] from "version_services" instead. *)letcommit_hash=Tezos_rpc.Service.get_service~description:"DEPRECATED: use `version` instead."~query:Tezos_rpc.Query.empty~output:stringTezos_rpc.Path.(path/"commit_hash")letactive_chains=Tezos_rpc.Service.get_service~description:"Monitor every chain creation and destruction. Currently active chains \
will be given as first elements"~query:Tezos_rpc.Query.empty~output:(Data_encoding.listchain_status_encoding)Tezos_rpc.Path.(path/"active_chains")endopenTezos_rpc.Contextletbootstrappedctxt=make_streamed_callS.bootstrappedctxt()()()letvalidated_blocksctxt?(chains=[`Main])?(protocols=[])?(next_protocols=[])()=make_streamed_callS.validated_blocksctxt()(objectmethodchains=chainsmethodprotocols=protocolsmethodnext_protocols=next_protocolsend)()letapplied_blocksctxt?(chains=[`Main])?(protocols=[])?(next_protocols=[])()=make_streamed_callS.applied_blocksctxt()(objectmethodchains=chainsmethodprotocols=protocolsmethodnext_protocols=next_protocolsend)()letheadsctxt?(protocols=[])?(next_protocols=[])chain=make_streamed_callS.headsctxt((),chain)(objectmethodprotocols=protocolsmethodnext_protocols=next_protocolsend)()letprotocolsctxt=make_streamed_callS.protocolsctxt()()()letcommit_hashctxt=make_callS.commit_hashctxt()()()letactive_chainsctxt=make_streamed_callS.active_chainsctxt()()()