2018-04-21 14:57:30 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
module S = struct
|
|
|
|
|
|
|
|
open Data_encoding
|
2018-04-21 16:21:46 +04:00
|
|
|
|
2018-04-21 14:57:30 +04:00
|
|
|
let path = RPC_path.(root / "monitor")
|
|
|
|
|
2018-04-21 16:21:46 +04:00
|
|
|
let bootstrapped =
|
|
|
|
RPC_service.get_service
|
2018-06-05 18:50:51 +04:00
|
|
|
~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."
|
2018-04-21 16:21:46 +04:00
|
|
|
~query: RPC_query.empty
|
|
|
|
~output: (obj2
|
|
|
|
(req "block" Block_hash.encoding)
|
|
|
|
(req "timestamp" Time.encoding))
|
|
|
|
RPC_path.(path / "bootstrapped")
|
|
|
|
|
2018-04-21 14:57:30 +04:00
|
|
|
let valid_blocks_query =
|
|
|
|
let open RPC_query in
|
|
|
|
query (fun protocols next_protocols chains -> object
|
|
|
|
method protocols = protocols
|
|
|
|
method next_protocols = next_protocols
|
|
|
|
method chains = chains
|
|
|
|
end)
|
|
|
|
|+ multi_field "protocol"
|
|
|
|
Protocol_hash.rpc_arg (fun t -> t#protocols)
|
|
|
|
|+ multi_field "next_protocol"
|
|
|
|
Protocol_hash.rpc_arg (fun t -> t#next_protocols)
|
|
|
|
|+ multi_field "chain"
|
|
|
|
Chain_services.chain_arg (fun t -> t#chains)
|
|
|
|
|> seal
|
|
|
|
|
|
|
|
let valid_blocks =
|
|
|
|
RPC_service.get_service
|
2018-06-05 18:50:51 +04:00
|
|
|
~description:"Monitor all blocks that are succesfully validated \
|
|
|
|
by the node, disregarding whether they were \
|
|
|
|
selected as the new head or not."
|
2018-04-21 14:57:30 +04:00
|
|
|
~query: valid_blocks_query
|
2018-06-06 17:15:44 +04:00
|
|
|
~output: (merge_objs
|
|
|
|
(obj2
|
|
|
|
(req "chain_id" Chain_id.encoding)
|
|
|
|
(req "hash" Block_hash.encoding))
|
|
|
|
Block_header.encoding)
|
2018-04-21 14:57:30 +04:00
|
|
|
RPC_path.(path / "valid_blocks")
|
|
|
|
|
|
|
|
let heads_query =
|
|
|
|
let open RPC_query in
|
|
|
|
query (fun next_protocols -> object
|
|
|
|
method next_protocols = next_protocols
|
|
|
|
end)
|
|
|
|
|+ multi_field "next_protocol"
|
|
|
|
Protocol_hash.rpc_arg (fun t -> t#next_protocols)
|
|
|
|
|> seal
|
|
|
|
|
|
|
|
let heads =
|
|
|
|
RPC_service.get_service
|
2018-06-05 18:50:51 +04:00
|
|
|
~description:"Monitor all blocks that are succesfully validated \
|
|
|
|
by the node and selected as the new head of the \
|
|
|
|
given chain."
|
2018-04-21 14:57:30 +04:00
|
|
|
~query: heads_query
|
2018-06-06 17:15:44 +04:00
|
|
|
~output: (merge_objs
|
|
|
|
(obj1
|
|
|
|
(req "hash" Block_hash.encoding))
|
|
|
|
Block_header.encoding)
|
2018-04-21 14:57:30 +04:00
|
|
|
RPC_path.(path / "heads" /: Chain_services.chain_arg)
|
|
|
|
|
2018-04-21 15:09:59 +04:00
|
|
|
let protocols =
|
|
|
|
RPC_service.get_service
|
2018-06-05 18:50:51 +04:00
|
|
|
~description:"Monitor all economic protocols that are retrieved \
|
|
|
|
and succesfully loaded and compiled by the node."
|
2018-04-21 15:09:59 +04:00
|
|
|
~query: RPC_query.empty
|
|
|
|
~output: Protocol_hash.encoding
|
|
|
|
RPC_path.(path / "protocols")
|
|
|
|
|
2018-04-21 14:57:30 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
open RPC_context
|
|
|
|
|
2018-04-21 16:21:46 +04:00
|
|
|
let bootstrapped ctxt =
|
|
|
|
make_streamed_call S.bootstrapped ctxt () () ()
|
|
|
|
|
2018-04-21 14:57:30 +04:00
|
|
|
let valid_blocks
|
|
|
|
ctxt ?(chains = [`Main]) ?(protocols = []) ?(next_protocols = []) () =
|
|
|
|
make_streamed_call S.valid_blocks ctxt () (object
|
|
|
|
method chains = chains
|
|
|
|
method protocols = protocols
|
|
|
|
method next_protocols = next_protocols
|
|
|
|
end) ()
|
|
|
|
|
|
|
|
let heads ctxt ?(next_protocols = []) chain =
|
|
|
|
make_streamed_call S.heads ctxt ((), chain) (object
|
|
|
|
method next_protocols = next_protocols
|
|
|
|
end) ()
|
2018-04-21 15:09:59 +04:00
|
|
|
|
|
|
|
let protocols ctxt =
|
|
|
|
make_streamed_call S.protocols ctxt () () ()
|